openpond-sdk 0.3.3 → 0.4.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/TASKSETS.md +55 -0
- package/dist/actions-local.js +67 -118
- package/dist/actions-local.js.map +4 -4
- package/dist/actions.js +4 -92
- package/dist/actions.js.map +4 -4
- package/dist/chunk-27ETSPHQ.js +83 -0
- package/dist/chunk-27ETSPHQ.js.map +7 -0
- package/dist/chunk-5PRP457R.js +477 -0
- package/dist/chunk-5PRP457R.js.map +7 -0
- package/dist/chunk-65D4C7HP.js +273 -0
- package/dist/chunk-65D4C7HP.js.map +7 -0
- package/dist/chunk-747CMU2Y.js +222 -0
- package/dist/chunk-747CMU2Y.js.map +7 -0
- package/dist/chunk-7O5X7DBU.js +80 -0
- package/dist/chunk-7O5X7DBU.js.map +7 -0
- package/dist/chunk-A4ZDOZKP.js +115 -0
- package/dist/chunk-A4ZDOZKP.js.map +7 -0
- package/dist/chunk-APHPXQEA.js +155 -0
- package/dist/chunk-APHPXQEA.js.map +7 -0
- package/dist/chunk-AVW35YOH.js +574 -0
- package/dist/chunk-AVW35YOH.js.map +7 -0
- package/dist/chunk-AZUCY3E5.js +2395 -0
- package/dist/chunk-AZUCY3E5.js.map +7 -0
- package/dist/chunk-IVEXCIHO.js +1373 -0
- package/dist/chunk-IVEXCIHO.js.map +7 -0
- package/dist/chunk-K5ZCYOZO.js +49 -0
- package/dist/chunk-K5ZCYOZO.js.map +7 -0
- package/dist/chunk-LLHE4BOD.js +220 -0
- package/dist/chunk-LLHE4BOD.js.map +7 -0
- package/dist/chunk-LXXQVGQY.js +1 -0
- package/dist/chunk-LXXQVGQY.js.map +7 -0
- package/dist/chunk-P27DQ65Z.js +138 -0
- package/dist/chunk-P27DQ65Z.js.map +7 -0
- package/dist/chunk-QLEJOCQX.js +72 -0
- package/dist/chunk-QLEJOCQX.js.map +7 -0
- package/dist/chunk-S7I45WJQ.js +57 -0
- package/dist/chunk-S7I45WJQ.js.map +7 -0
- package/dist/chunk-ZPCK222K.js +586 -0
- package/dist/chunk-ZPCK222K.js.map +7 -0
- package/dist/index.js +33 -2488
- package/dist/index.js.map +4 -4
- package/dist/learning.js +16 -2042
- package/dist/learning.js.map +4 -4
- package/dist/model-batch-review.js +5 -42
- package/dist/model-batch-review.js.map +3 -3
- package/dist/model-projects.js +29 -430
- package/dist/model-projects.js.map +3 -3
- package/dist/model-starter-attempts.js +53 -310
- package/dist/model-starter-attempts.js.map +4 -4
- package/dist/model-starter-catalog.js +17 -460
- package/dist/model-starter-catalog.js.map +4 -4
- package/dist/model-starters.js +32 -709
- package/dist/model-starters.js.map +4 -4
- package/dist/model-taskset-authoring.js +11 -44
- package/dist/model-taskset-authoring.js.map +3 -3
- package/dist/profile-actions.js +4 -211
- package/dist/profile-actions.js.map +3 -3
- package/dist/project-actions.js +4 -224
- package/dist/project-actions.js.map +3 -3
- package/dist/refiner.js +14 -554
- package/dist/refiner.js.map +4 -4
- package/dist/taskset-catalog.js +9 -104
- package/dist/taskset-catalog.js.map +3 -3
- package/dist/taskset-drafts.js +465 -0
- package/dist/taskset-drafts.js.map +7 -0
- package/dist/taskset-packages.js +946 -3089
- package/dist/taskset-packages.js.map +4 -4
- package/dist/training.js +43 -822
- package/dist/training.js.map +4 -4
- package/dist/types/packages/sdk/src/index.d.ts +3 -3
- package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/learning-client.d.ts +130 -0
- package/dist/types/packages/sdk/src/learning-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/learning.d.ts +1 -129
- package/dist/types/packages/sdk/src/learning.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts +1170 -0
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts +560 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts +92 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts +15 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts +18 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts +1681 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts +19 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +2713 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts +1000 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts +429 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts +284 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts +846 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts +28 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts +967 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts +10 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts +1297 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts +1597 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts +16 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts +64 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts +1514 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts +6 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -1
- package/dist/workflows.js +4 -221
- package/dist/workflows.js.map +3 -3
- package/package.json +5 -1
package/dist/taskset-packages.js
CHANGED
|
@@ -1,3089 +1,118 @@
|
|
|
1
|
-
// src/taskset-package-contracts.ts
|
|
2
|
-
import { z as z19 } from "zod";
|
|
3
|
-
|
|
4
|
-
// ../harness/dist/common.js
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
|
|
7
|
-
// ../harness/dist/sha256.js
|
|
8
|
-
var INITIAL_STATE = new Uint32Array([
|
|
9
|
-
1779033703,
|
|
10
|
-
3144134277,
|
|
11
|
-
1013904242,
|
|
12
|
-
2773480762,
|
|
13
|
-
1359893119,
|
|
14
|
-
2600822924,
|
|
15
|
-
528734635,
|
|
16
|
-
1541459225
|
|
17
|
-
]);
|
|
18
|
-
var ROUND_CONSTANTS = new Uint32Array([
|
|
19
|
-
1116352408,
|
|
20
|
-
1899447441,
|
|
21
|
-
3049323471,
|
|
22
|
-
3921009573,
|
|
23
|
-
961987163,
|
|
24
|
-
1508970993,
|
|
25
|
-
2453635748,
|
|
26
|
-
2870763221,
|
|
27
|
-
3624381080,
|
|
28
|
-
310598401,
|
|
29
|
-
607225278,
|
|
30
|
-
1426881987,
|
|
31
|
-
1925078388,
|
|
32
|
-
2162078206,
|
|
33
|
-
2614888103,
|
|
34
|
-
3248222580,
|
|
35
|
-
3835390401,
|
|
36
|
-
4022224774,
|
|
37
|
-
264347078,
|
|
38
|
-
604807628,
|
|
39
|
-
770255983,
|
|
40
|
-
1249150122,
|
|
41
|
-
1555081692,
|
|
42
|
-
1996064986,
|
|
43
|
-
2554220882,
|
|
44
|
-
2821834349,
|
|
45
|
-
2952996808,
|
|
46
|
-
3210313671,
|
|
47
|
-
3336571891,
|
|
48
|
-
3584528711,
|
|
49
|
-
113926993,
|
|
50
|
-
338241895,
|
|
51
|
-
666307205,
|
|
52
|
-
773529912,
|
|
53
|
-
1294757372,
|
|
54
|
-
1396182291,
|
|
55
|
-
1695183700,
|
|
56
|
-
1986661051,
|
|
57
|
-
2177026350,
|
|
58
|
-
2456956037,
|
|
59
|
-
2730485921,
|
|
60
|
-
2820302411,
|
|
61
|
-
3259730800,
|
|
62
|
-
3345764771,
|
|
63
|
-
3516065817,
|
|
64
|
-
3600352804,
|
|
65
|
-
4094571909,
|
|
66
|
-
275423344,
|
|
67
|
-
430227734,
|
|
68
|
-
506948616,
|
|
69
|
-
659060556,
|
|
70
|
-
883997877,
|
|
71
|
-
958139571,
|
|
72
|
-
1322822218,
|
|
73
|
-
1537002063,
|
|
74
|
-
1747873779,
|
|
75
|
-
1955562222,
|
|
76
|
-
2024104815,
|
|
77
|
-
2227730452,
|
|
78
|
-
2361852424,
|
|
79
|
-
2428436474,
|
|
80
|
-
2756734187,
|
|
81
|
-
3204031479,
|
|
82
|
-
3329325298
|
|
83
|
-
]);
|
|
84
|
-
function sha256Hex(value) {
|
|
85
|
-
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
86
|
-
const paddedLength = Math.ceil((bytes.byteLength + 9) / 64) * 64;
|
|
87
|
-
const padded = new Uint8Array(paddedLength);
|
|
88
|
-
padded.set(bytes);
|
|
89
|
-
padded[bytes.byteLength] = 128;
|
|
90
|
-
const bitLength = bytes.byteLength * 8;
|
|
91
|
-
const view = new DataView(padded.buffer);
|
|
92
|
-
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296), false);
|
|
93
|
-
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
94
|
-
const state = new Uint32Array(INITIAL_STATE);
|
|
95
|
-
const words = new Uint32Array(64);
|
|
96
|
-
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
97
|
-
for (let index = 0; index < 16; index += 1) {
|
|
98
|
-
words[index] = view.getUint32(offset + index * 4, false);
|
|
99
|
-
}
|
|
100
|
-
for (let index = 16; index < 64; index += 1) {
|
|
101
|
-
const previous = words[index - 15];
|
|
102
|
-
const recent = words[index - 2];
|
|
103
|
-
const sigma0 = rotateRight(previous, 7) ^ rotateRight(previous, 18) ^ previous >>> 3;
|
|
104
|
-
const sigma1 = rotateRight(recent, 17) ^ rotateRight(recent, 19) ^ recent >>> 10;
|
|
105
|
-
words[index] = words[index - 16] + sigma0 + words[index - 7] + sigma1 >>> 0;
|
|
106
|
-
}
|
|
107
|
-
let a = state[0];
|
|
108
|
-
let b = state[1];
|
|
109
|
-
let c = state[2];
|
|
110
|
-
let d = state[3];
|
|
111
|
-
let e = state[4];
|
|
112
|
-
let f = state[5];
|
|
113
|
-
let g = state[6];
|
|
114
|
-
let h = state[7];
|
|
115
|
-
for (let index = 0; index < 64; index += 1) {
|
|
116
|
-
const choice = e & f ^ ~e & g;
|
|
117
|
-
const majority = a & b ^ a & c ^ b & c;
|
|
118
|
-
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
119
|
-
const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
120
|
-
const first = h + sum1 + choice + ROUND_CONSTANTS[index] + words[index] >>> 0;
|
|
121
|
-
const second = sum0 + majority >>> 0;
|
|
122
|
-
h = g;
|
|
123
|
-
g = f;
|
|
124
|
-
f = e;
|
|
125
|
-
e = d + first >>> 0;
|
|
126
|
-
d = c;
|
|
127
|
-
c = b;
|
|
128
|
-
b = a;
|
|
129
|
-
a = first + second >>> 0;
|
|
130
|
-
}
|
|
131
|
-
state[0] = state[0] + a >>> 0;
|
|
132
|
-
state[1] = state[1] + b >>> 0;
|
|
133
|
-
state[2] = state[2] + c >>> 0;
|
|
134
|
-
state[3] = state[3] + d >>> 0;
|
|
135
|
-
state[4] = state[4] + e >>> 0;
|
|
136
|
-
state[5] = state[5] + f >>> 0;
|
|
137
|
-
state[6] = state[6] + g >>> 0;
|
|
138
|
-
state[7] = state[7] + h >>> 0;
|
|
139
|
-
}
|
|
140
|
-
return Array.from(state, (word) => word.toString(16).padStart(8, "0")).join("");
|
|
141
|
-
}
|
|
142
|
-
function rotateRight(value, bits) {
|
|
143
|
-
return value >>> bits | value << 32 - bits;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ../harness/dist/common.js
|
|
147
|
-
var MAX_PORTABLE_PATH_BYTES = 2e3;
|
|
148
|
-
var MAX_PORTABLE_ASSET_BYTES = 25e7;
|
|
149
|
-
var ReleaseIdSchema = z.string().trim().min(1).max(240);
|
|
150
|
-
var ReleaseHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
151
|
-
var ReleaseTimestampSchema = z.string().datetime({ offset: true });
|
|
152
|
-
var MetadataSchema = z.record(z.string(), z.unknown()).default({});
|
|
153
|
-
var ImmutableReleaseRefSchema = z.object({
|
|
154
|
-
id: ReleaseIdSchema,
|
|
155
|
-
contentHash: ReleaseHashSchema
|
|
156
|
-
}).strict();
|
|
157
|
-
var ImmutableAssetRefSchema = z.object({
|
|
158
|
-
id: ReleaseIdSchema,
|
|
159
|
-
path: z.string().trim().min(1).max(MAX_PORTABLE_PATH_BYTES).refine(safeRelativePath),
|
|
160
|
-
contentHash: ReleaseHashSchema,
|
|
161
|
-
sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES),
|
|
162
|
-
mediaType: z.string().trim().min(1).max(200),
|
|
163
|
-
visibility: z.enum(["policy", "verifier", "host_private"])
|
|
164
|
-
}).strict();
|
|
165
|
-
var ImmutableArtifactRefSchema = z.object({
|
|
166
|
-
id: ReleaseIdSchema,
|
|
167
|
-
contentHash: ReleaseHashSchema,
|
|
168
|
-
mediaType: z.string().trim().min(1).max(200).nullable().default(null),
|
|
169
|
-
sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES).nullable().default(null)
|
|
170
|
-
}).strict();
|
|
171
|
-
var FailureClassSchema = z.enum([
|
|
172
|
-
"policy_failure",
|
|
173
|
-
"grader_failure",
|
|
174
|
-
"environment_failure",
|
|
175
|
-
"infrastructure_failure",
|
|
176
|
-
"timeout",
|
|
177
|
-
"cancelled"
|
|
178
|
-
]);
|
|
179
|
-
function canonicalJson(value) {
|
|
180
|
-
return `${JSON.stringify(sortValue(value), null, 2)}
|
|
181
|
-
`;
|
|
182
|
-
}
|
|
183
|
-
function sha256(value) {
|
|
184
|
-
return sha256Hex(value);
|
|
185
|
-
}
|
|
186
|
-
function contentHash(value) {
|
|
187
|
-
return sha256(canonicalJson(value));
|
|
188
|
-
}
|
|
189
|
-
function safeRelativePath(value) {
|
|
190
|
-
const normalized = value.replaceAll("\\", "/");
|
|
191
|
-
if (!normalized || normalized.startsWith("/") || normalized.includes("\0"))
|
|
192
|
-
return false;
|
|
193
|
-
return !normalized.split("/").some((part) => !part || part === "." || part === "..");
|
|
194
|
-
}
|
|
195
|
-
function sortValue(value) {
|
|
196
|
-
if (Array.isArray(value))
|
|
197
|
-
return value.map(sortValue);
|
|
198
|
-
if (!value || typeof value !== "object")
|
|
199
|
-
return value;
|
|
200
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortValue(child)]));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ../harness/dist/evaluation-review.js
|
|
204
|
-
import { z as z2 } from "zod";
|
|
205
|
-
var BoundedTextSchema = z2.string().trim().min(1).max(1e5);
|
|
206
|
-
var HarnessEvaluationReviewClassificationSchema = z2.enum([
|
|
207
|
-
"no_action",
|
|
208
|
-
"harness_maintenance",
|
|
209
|
-
"runtime",
|
|
210
|
-
"product",
|
|
211
|
-
"taskset",
|
|
212
|
-
"model_improvement"
|
|
213
|
-
]);
|
|
214
|
-
var HarnessEvaluationReviewAuthoritySchema = z2.enum([
|
|
215
|
-
"none",
|
|
216
|
-
"runtime_service",
|
|
217
|
-
"product_team",
|
|
218
|
-
"human_review",
|
|
219
|
-
"evaluation_system",
|
|
220
|
-
"training_system"
|
|
221
|
-
]);
|
|
222
|
-
var HarnessReviewEvidenceKindSchema = z2.enum([
|
|
223
|
-
"observation",
|
|
224
|
-
"trigger",
|
|
225
|
-
"route_decision",
|
|
226
|
-
"refiner_outcome",
|
|
227
|
-
"proposal",
|
|
228
|
-
"validation",
|
|
229
|
-
"apply_receipt",
|
|
230
|
-
"harness_advance",
|
|
231
|
-
"rollback",
|
|
232
|
-
"work_outcome",
|
|
233
|
-
"taskset",
|
|
234
|
-
"evaluation",
|
|
235
|
-
"training_qualification",
|
|
236
|
-
"model_candidate"
|
|
237
|
-
]);
|
|
238
|
-
var HarnessReviewOwnerScopeSchema = z2.object({
|
|
239
|
-
kind: z2.enum(["personal", "team"]),
|
|
240
|
-
id: ReleaseIdSchema
|
|
241
|
-
}).strict();
|
|
242
|
-
var HarnessReviewSourcePolicyRefSchema = z2.object({
|
|
243
|
-
policy: ImmutableReleaseRefSchema,
|
|
244
|
-
state: z2.enum(["authorized", "revoked", "deleted", "expired"]),
|
|
245
|
-
checkedAt: ReleaseTimestampSchema
|
|
246
|
-
}).strict();
|
|
247
|
-
var HarnessReviewEvidenceRefSchema = z2.object({
|
|
248
|
-
evidence: ImmutableReleaseRefSchema,
|
|
249
|
-
kind: HarnessReviewEvidenceKindSchema,
|
|
250
|
-
sourceRef: ReleaseIdSchema,
|
|
251
|
-
sourcePolicy: HarnessReviewSourcePolicyRefSchema,
|
|
252
|
-
occurrenceKey: ReleaseHashSchema,
|
|
253
|
-
occurredAt: ReleaseTimestampSchema
|
|
254
|
-
}).strict();
|
|
255
|
-
var HarnessReviewExcludedEvidenceSchema = z2.object({
|
|
256
|
-
evidence: ImmutableReleaseRefSchema,
|
|
257
|
-
sourcePolicy: HarnessReviewSourcePolicyRefSchema.nullable(),
|
|
258
|
-
reason: z2.enum([
|
|
259
|
-
"outside_scope",
|
|
260
|
-
"before_watermark",
|
|
261
|
-
"duplicate",
|
|
262
|
-
"resolved",
|
|
263
|
-
"revoked",
|
|
264
|
-
"deleted",
|
|
265
|
-
"expired",
|
|
266
|
-
"sensitive",
|
|
267
|
-
"unverified",
|
|
268
|
-
"budget"
|
|
269
|
-
])
|
|
270
|
-
}).strict();
|
|
271
|
-
var HarnessReviewWatermarkSchema = z2.object({
|
|
272
|
-
cursor: ReleaseHashSchema,
|
|
273
|
-
throughCreatedAt: ReleaseTimestampSchema
|
|
274
|
-
}).strict();
|
|
275
|
-
var HarnessReviewClaimSchema = z2.object({
|
|
276
|
-
fingerprint: ReleaseHashSchema,
|
|
277
|
-
recurrenceFamily: z2.string().trim().min(1).max(1e3),
|
|
278
|
-
statement: BoundedTextSchema,
|
|
279
|
-
candidateDisposition: z2.enum(["observe", "confirm"]).optional(),
|
|
280
|
-
independentOccurrences: z2.number().int().positive().max(1e6),
|
|
281
|
-
unresolvedOccurrences: z2.number().int().positive().max(1e6)
|
|
282
|
-
}).strict().refine((claim) => claim.unresolvedOccurrences <= claim.independentOccurrences, "unresolved occurrences cannot exceed independent occurrences");
|
|
283
|
-
var HarnessReviewTriageLayerSchema = z2.enum([
|
|
284
|
-
"harness",
|
|
285
|
-
"runtime",
|
|
286
|
-
"product",
|
|
287
|
-
"retrieval",
|
|
288
|
-
"tools",
|
|
289
|
-
"evaluation",
|
|
290
|
-
"model"
|
|
291
|
-
]);
|
|
292
|
-
var HarnessReviewTriageDecisionSchema = z2.object({
|
|
293
|
-
layer: HarnessReviewTriageLayerSchema,
|
|
294
|
-
status: z2.enum(["not_applicable", "unresolved", "resolved", "blocked"]),
|
|
295
|
-
reason: BoundedTextSchema,
|
|
296
|
-
evidenceRefs: z2.array(ImmutableReleaseRefSchema).max(1e3)
|
|
297
|
-
}).strict();
|
|
298
|
-
var HarnessEvaluationReviewReceiptContentSchema = z2.object({
|
|
299
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewReceipt.v1"),
|
|
300
|
-
id: ReleaseIdSchema,
|
|
301
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
302
|
-
workspaceRef: ReleaseIdSchema,
|
|
303
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
304
|
-
previousWatermark: HarnessReviewWatermarkSchema.nullable(),
|
|
305
|
-
nextWatermark: HarnessReviewWatermarkSchema,
|
|
306
|
-
selectedEvidence: z2.array(HarnessReviewEvidenceRefSchema).max(1e4),
|
|
307
|
-
excludedEvidence: z2.array(HarnessReviewExcludedEvidenceSchema).max(1e4),
|
|
308
|
-
claim: HarnessReviewClaimSchema.nullable(),
|
|
309
|
-
classification: HarnessEvaluationReviewClassificationSchema,
|
|
310
|
-
triage: z2.array(HarnessReviewTriageDecisionSchema).max(16),
|
|
311
|
-
reason: BoundedTextSchema,
|
|
312
|
-
nextAuthority: HarnessEvaluationReviewAuthoritySchema,
|
|
313
|
-
maxEstimatedCostUsd: z2.number().finite().nonnegative(),
|
|
314
|
-
tasksetProposal: ImmutableReleaseRefSchema.nullable(),
|
|
315
|
-
evaluation: ImmutableReleaseRefSchema.nullable(),
|
|
316
|
-
trainingQualification: ImmutableReleaseRefSchema.nullable(),
|
|
317
|
-
policyVersion: ReleaseIdSchema,
|
|
318
|
-
createdAt: ReleaseTimestampSchema,
|
|
319
|
-
metadata: MetadataSchema
|
|
320
|
-
}).strict().superRefine((receipt, context) => {
|
|
321
|
-
const selectedKeys = receipt.selectedEvidence.map((item) => `${item.evidence.id}:${item.evidence.contentHash}`);
|
|
322
|
-
if (new Set(selectedKeys).size !== selectedKeys.length) {
|
|
323
|
-
context.addIssue({
|
|
324
|
-
code: "custom",
|
|
325
|
-
message: "selected review evidence must be unique",
|
|
326
|
-
path: ["selectedEvidence"]
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
if (receipt.selectedEvidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
330
|
-
context.addIssue({
|
|
331
|
-
code: "custom",
|
|
332
|
-
message: "selected review evidence must be authorized at review time",
|
|
333
|
-
path: ["selectedEvidence"]
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
if (receipt.classification === "no_action") {
|
|
337
|
-
if (receipt.nextAuthority !== "none") {
|
|
338
|
-
context.addIssue({
|
|
339
|
-
code: "custom",
|
|
340
|
-
message: "no-action review receipts require no next authority",
|
|
341
|
-
path: ["nextAuthority"]
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
if (receipt.tasksetProposal || receipt.evaluation || receipt.trainingQualification) {
|
|
345
|
-
context.addIssue({
|
|
346
|
-
code: "custom",
|
|
347
|
-
message: "no-action review receipts cannot carry downstream refs"
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
} else if (!receipt.claim || receipt.selectedEvidence.length === 0) {
|
|
351
|
-
context.addIssue({
|
|
352
|
-
code: "custom",
|
|
353
|
-
message: "actionable review receipts require a claim and selected evidence"
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
if (receipt.classification === "runtime" && receipt.nextAuthority !== "runtime_service") {
|
|
357
|
-
context.addIssue({
|
|
358
|
-
code: "custom",
|
|
359
|
-
message: "runtime classifications route to runtime-service authority",
|
|
360
|
-
path: ["nextAuthority"]
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
if (receipt.classification === "product" && receipt.nextAuthority !== "product_team") {
|
|
364
|
-
context.addIssue({
|
|
365
|
-
code: "custom",
|
|
366
|
-
message: "product classifications route to product-team authority",
|
|
367
|
-
path: ["nextAuthority"]
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
if (receipt.classification === "taskset" && receipt.nextAuthority !== "human_review") {
|
|
371
|
-
context.addIssue({
|
|
372
|
-
code: "custom",
|
|
373
|
-
message: "Taskset classifications require human review"
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
if (receipt.classification === "model_improvement" && (!receipt.evaluation || !receipt.trainingQualification || !["human_review", "training_system"].includes(receipt.nextAuthority))) {
|
|
377
|
-
context.addIssue({
|
|
378
|
-
code: "custom",
|
|
379
|
-
message: "model-improvement classifications require Evaluation and qualification refs plus explicit authority"
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
var HarnessEvaluationReviewReceiptSchema = HarnessEvaluationReviewReceiptContentSchema.extend({
|
|
384
|
-
contentHash: ReleaseHashSchema
|
|
385
|
-
}).strict();
|
|
386
|
-
var HarnessEvaluationReviewModelEvidenceSchema = z2.object({
|
|
387
|
-
id: ReleaseIdSchema,
|
|
388
|
-
evidence: ImmutableReleaseRefSchema,
|
|
389
|
-
kind: HarnessReviewEvidenceKindSchema,
|
|
390
|
-
sourceRef: ReleaseIdSchema,
|
|
391
|
-
occurredAt: ReleaseTimestampSchema,
|
|
392
|
-
payload: z2.record(z2.string(), z2.unknown())
|
|
393
|
-
}).strict();
|
|
394
|
-
var HarnessEvaluationReviewModelNoActionSchema = z2.object({
|
|
395
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
396
|
-
decision: z2.literal("no_action"),
|
|
397
|
-
reason: BoundedTextSchema,
|
|
398
|
-
ignoredEvidence: z2.array(z2.object({
|
|
399
|
-
id: ReleaseIdSchema,
|
|
400
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
401
|
-
}).strict()).max(1e3)
|
|
402
|
-
}).strict();
|
|
403
|
-
var HarnessEvaluationReviewModelActionSchema = z2.object({
|
|
404
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
405
|
-
decision: z2.literal("review"),
|
|
406
|
-
classification: z2.enum([
|
|
407
|
-
"harness_maintenance",
|
|
408
|
-
"runtime",
|
|
409
|
-
"product",
|
|
410
|
-
"taskset"
|
|
411
|
-
]),
|
|
412
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(1e3),
|
|
413
|
-
ignoredEvidence: z2.array(z2.object({
|
|
414
|
-
id: ReleaseIdSchema,
|
|
415
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
416
|
-
}).strict()).max(1e3),
|
|
417
|
-
recurrenceFamily: z2.string().trim().min(1).max(1e3),
|
|
418
|
-
statement: BoundedTextSchema,
|
|
419
|
-
triageLayer: HarnessReviewTriageLayerSchema,
|
|
420
|
-
expectedOutcome: BoundedTextSchema,
|
|
421
|
-
counterevidence: z2.string().trim().max(1e4),
|
|
422
|
-
confidence: z2.number().min(0).max(1),
|
|
423
|
-
candidateDisposition: z2.enum(["observe", "confirm"]).nullable(),
|
|
424
|
-
reason: BoundedTextSchema
|
|
425
|
-
}).strict().superRefine((decision, context) => {
|
|
426
|
-
const requiresDisposition = decision.classification === "harness_maintenance";
|
|
427
|
-
if (requiresDisposition !== (decision.candidateDisposition !== null)) {
|
|
428
|
-
context.addIssue({
|
|
429
|
-
code: "custom",
|
|
430
|
-
message: "Harness maintenance requires a candidate disposition; external routes require null",
|
|
431
|
-
path: ["candidateDisposition"]
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
var HarnessEvaluationReviewModelResolutionSchema = z2.object({
|
|
436
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
437
|
-
decision: z2.literal("resolve_candidate"),
|
|
438
|
-
candidateId: ReleaseIdSchema,
|
|
439
|
-
candidateFingerprint: ReleaseHashSchema,
|
|
440
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(1e3),
|
|
441
|
-
ignoredEvidence: z2.array(z2.object({
|
|
442
|
-
id: ReleaseIdSchema,
|
|
443
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
444
|
-
}).strict()).max(1e3),
|
|
445
|
-
confidence: z2.number().min(0).max(1),
|
|
446
|
-
reason: BoundedTextSchema
|
|
447
|
-
}).strict();
|
|
448
|
-
var HarnessEvaluationReviewModelDecisionSchema = z2.discriminatedUnion("decision", [
|
|
449
|
-
HarnessEvaluationReviewModelNoActionSchema,
|
|
450
|
-
HarnessEvaluationReviewModelActionSchema,
|
|
451
|
-
HarnessEvaluationReviewModelResolutionSchema
|
|
452
|
-
]);
|
|
453
|
-
var HarnessEvaluationReviewNavigationDecisionSchema = z2.object({
|
|
454
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewNavigationDecision.v1"),
|
|
455
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(50),
|
|
456
|
-
reason: BoundedTextSchema
|
|
457
|
-
}).strict();
|
|
458
|
-
|
|
459
|
-
// ../harness/dist/harness.js
|
|
460
|
-
import { z as z4 } from "zod";
|
|
461
|
-
|
|
462
|
-
// ../harness/dist/tools.js
|
|
463
|
-
import { z as z3 } from "zod";
|
|
464
|
-
var ToolDeclarationSchema = z3.object({
|
|
465
|
-
name: z3.string().trim().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/),
|
|
466
|
-
description: z3.string().trim().min(1).max(2e3),
|
|
467
|
-
inputSchema: z3.record(z3.string(), z3.unknown()),
|
|
468
|
-
inputSchemaHash: ReleaseHashSchema,
|
|
469
|
-
sideEffect: z3.enum(["read", "write"]),
|
|
470
|
-
timeoutMs: z3.number().int().positive().max(36e5)
|
|
471
|
-
}).strict();
|
|
472
|
-
var CapabilityRequirementSchema = z3.object({
|
|
473
|
-
id: ReleaseIdSchema,
|
|
474
|
-
required: z3.boolean(),
|
|
475
|
-
scopes: z3.array(z3.string().trim().min(1).max(500)).max(100).default([]),
|
|
476
|
-
portability: z3.enum(["portable", "host_adapter", "local_only", "hosted_only"])
|
|
477
|
-
}).strict();
|
|
478
|
-
|
|
479
|
-
// ../harness/dist/harness.js
|
|
480
|
-
var PortabilityReportSchema = z4.object({
|
|
481
|
-
portable: z4.boolean(),
|
|
482
|
-
blockers: z4.array(z4.string().trim().min(1).max(2e3)).max(1e3),
|
|
483
|
-
localOnlyAssetRefs: z4.array(ReleaseIdSchema).max(1e4),
|
|
484
|
-
hostPrivateAssetRefs: z4.array(ReleaseIdSchema).max(1e4)
|
|
485
|
-
}).strict();
|
|
486
|
-
var AgentSnapshotContentSchema = z4.object({
|
|
487
|
-
schemaVersion: z4.literal("openpond.agentSnapshot.v2"),
|
|
488
|
-
id: ReleaseIdSchema,
|
|
489
|
-
sourceRelease: ImmutableReleaseRefSchema.nullable(),
|
|
490
|
-
instructions: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
491
|
-
skills: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
492
|
-
agents: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
493
|
-
toolDeclarations: z4.array(ToolDeclarationSchema).max(200),
|
|
494
|
-
capabilityRequirements: z4.array(CapabilityRequirementSchema).max(200),
|
|
495
|
-
dependencyLock: ImmutableAssetRefSchema,
|
|
496
|
-
portability: PortabilityReportSchema,
|
|
497
|
-
metadata: MetadataSchema
|
|
498
|
-
}).strict();
|
|
499
|
-
var AgentSnapshotSchema = AgentSnapshotContentSchema.extend({ contentHash: ReleaseHashSchema }).strict();
|
|
500
|
-
var LifecycleContractSchema = z4.object({
|
|
501
|
-
create: z4.literal(true),
|
|
502
|
-
reset: z4.literal(true),
|
|
503
|
-
step: z4.literal(true),
|
|
504
|
-
collect: z4.literal(true),
|
|
505
|
-
destroy: z4.literal(true),
|
|
506
|
-
resetScope: z4.enum(["task", "attempt"])
|
|
507
|
-
}).strict();
|
|
508
|
-
var GraderInterfaceContractSchema = z4.object({
|
|
509
|
-
visibleEvidence: z4.array(ReleaseIdSchema).max(1e3),
|
|
510
|
-
privilegedEvidence: z4.array(ReleaseIdSchema).max(1e3),
|
|
511
|
-
privateVerifierIsolation: z4.boolean()
|
|
512
|
-
}).strict();
|
|
513
|
-
var HarnessReleaseContentSchema = z4.object({
|
|
514
|
-
schemaVersion: z4.literal("openpond.harnessRelease.v2"),
|
|
515
|
-
id: ReleaseIdSchema,
|
|
516
|
-
agentSnapshot: ImmutableReleaseRefSchema,
|
|
517
|
-
program: ImmutableAssetRefSchema,
|
|
518
|
-
tools: z4.array(ToolDeclarationSchema).max(200),
|
|
519
|
-
lifecycle: LifecycleContractSchema,
|
|
520
|
-
graderInterface: GraderInterfaceContractSchema,
|
|
521
|
-
files: z4.array(ImmutableAssetRefSchema).max(1e5),
|
|
522
|
-
metadata: MetadataSchema
|
|
523
|
-
}).strict();
|
|
524
|
-
var HarnessReleaseSchema = HarnessReleaseContentSchema.extend({ contentHash: ReleaseHashSchema }).strict();
|
|
525
|
-
var ModelActionSchema = z4.object({
|
|
526
|
-
id: ReleaseIdSchema,
|
|
527
|
-
turn: z4.number().int().nonnegative(),
|
|
528
|
-
kind: z4.enum(["message", "tool_call", "terminal"]),
|
|
529
|
-
name: ReleaseIdSchema.nullable(),
|
|
530
|
-
arguments: z4.record(z4.string(), z4.unknown()),
|
|
531
|
-
content: z4.string().max(1e6).nullable()
|
|
532
|
-
}).strict();
|
|
533
|
-
var ToolObservationSchema = z4.object({
|
|
534
|
-
actionId: ReleaseIdSchema,
|
|
535
|
-
turn: z4.number().int().nonnegative(),
|
|
536
|
-
terminal: z4.boolean(),
|
|
537
|
-
output: z4.record(z4.string(), z4.unknown()),
|
|
538
|
-
artifactRefs: z4.array(ImmutableArtifactRefSchema).max(1e5)
|
|
539
|
-
}).strict();
|
|
540
|
-
var HarnessLifecycleEventSchema = z4.object({
|
|
541
|
-
sequence: z4.number().int().nonnegative(),
|
|
542
|
-
type: z4.enum(["created", "reset", "action", "observation", "terminal", "failure", "collected", "destroyed"]),
|
|
543
|
-
payloadHash: ReleaseHashSchema,
|
|
544
|
-
metadata: MetadataSchema
|
|
545
|
-
}).strict();
|
|
546
|
-
var HarnessTraceSchema = z4.object({
|
|
547
|
-
schemaVersion: z4.literal("openpond.harnessTrace.v1"),
|
|
548
|
-
manifest: ImmutableReleaseRefSchema,
|
|
549
|
-
taskId: ReleaseIdSchema,
|
|
550
|
-
seed: z4.string().trim().min(1).max(500),
|
|
551
|
-
events: z4.array(HarnessLifecycleEventSchema).max(1e6),
|
|
552
|
-
actions: z4.array(ModelActionSchema).max(1e5),
|
|
553
|
-
observations: z4.array(ToolObservationSchema).max(1e5),
|
|
554
|
-
terminal: z4.boolean(),
|
|
555
|
-
failureClass: FailureClassSchema.nullable(),
|
|
556
|
-
output: z4.record(z4.string(), z4.unknown()),
|
|
557
|
-
contentHash: ReleaseHashSchema
|
|
558
|
-
}).strict();
|
|
559
|
-
|
|
560
|
-
// ../harness/dist/harness-improvements.js
|
|
561
|
-
import { z as z6 } from "zod";
|
|
562
|
-
|
|
563
|
-
// ../harness/dist/harness-workspaces.js
|
|
564
|
-
import { z as z5 } from "zod";
|
|
565
|
-
var MetadataSchema2 = z5.record(z5.string(), z5.unknown()).default({});
|
|
566
|
-
var RevisionSchema = z5.number().int().nonnegative();
|
|
567
|
-
var BoundedTextSchema2 = z5.string().trim().min(1).max(1e5);
|
|
568
|
-
var HarnessOwnerScopeSchema = z5.object({
|
|
569
|
-
kind: z5.enum(["personal", "team"]),
|
|
570
|
-
id: ReleaseIdSchema
|
|
571
|
-
}).strict();
|
|
572
|
-
var HarnessCurrentChannelSchema = z5.object({
|
|
573
|
-
name: ReleaseIdSchema,
|
|
574
|
-
release: ImmutableReleaseRefSchema.nullable(),
|
|
575
|
-
revision: RevisionSchema
|
|
576
|
-
}).strict();
|
|
577
|
-
var HarnessWorkspaceSchema = z5.object({
|
|
578
|
-
schemaVersion: z5.literal("openpond.harnessWorkspace.v1"),
|
|
579
|
-
id: ReleaseIdSchema,
|
|
580
|
-
ownerScope: HarnessOwnerScopeSchema,
|
|
581
|
-
name: z5.string().trim().min(1).max(240),
|
|
582
|
-
location: z5.enum(["local", "hosted"]),
|
|
583
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
584
|
-
revision: RevisionSchema,
|
|
585
|
-
dirty: z5.boolean(),
|
|
586
|
-
currentChannel: HarnessCurrentChannelSchema,
|
|
587
|
-
createdAt: ReleaseTimestampSchema,
|
|
588
|
-
updatedAt: ReleaseTimestampSchema,
|
|
589
|
-
metadata: MetadataSchema2
|
|
590
|
-
}).strict();
|
|
591
|
-
var HarnessImprovementRouteSchema = z5.enum([
|
|
592
|
-
"runtime",
|
|
593
|
-
"memory",
|
|
594
|
-
"prompt",
|
|
595
|
-
"skill",
|
|
596
|
-
"agent",
|
|
597
|
-
"product",
|
|
598
|
-
"taskset",
|
|
599
|
-
"training"
|
|
600
|
-
]);
|
|
601
|
-
var HarnessChangeEffectSchema = z5.enum([
|
|
602
|
-
"text_instruction",
|
|
603
|
-
"memory",
|
|
604
|
-
"dependency_selection",
|
|
605
|
-
"executable_code",
|
|
606
|
-
"business_logic",
|
|
607
|
-
"financial_logic",
|
|
608
|
-
"permission",
|
|
609
|
-
"connected_app",
|
|
610
|
-
"publication",
|
|
611
|
-
"deployment",
|
|
612
|
-
"training",
|
|
613
|
-
"model_binding",
|
|
614
|
-
"team_or_global"
|
|
615
|
-
]);
|
|
616
|
-
var HarnessOverlayEditSchema = z5.object({
|
|
617
|
-
id: ReleaseIdSchema,
|
|
618
|
-
route: HarnessImprovementRouteSchema,
|
|
619
|
-
operation: z5.enum(["create", "update", "delete"]),
|
|
620
|
-
target: z5.string().trim().min(1).max(2e3),
|
|
621
|
-
summary: z5.string().trim().min(1).max(2e3),
|
|
622
|
-
content: z5.string().max(1e6).nullable(),
|
|
623
|
-
contentHash: ReleaseHashSchema.nullable(),
|
|
624
|
-
effects: z5.array(HarnessChangeEffectSchema).min(1).max(20)
|
|
625
|
-
}).strict().superRefine((edit, context) => {
|
|
626
|
-
if (edit.operation === "delete") {
|
|
627
|
-
if (edit.content !== null || edit.contentHash !== null) {
|
|
628
|
-
context.addIssue({
|
|
629
|
-
code: "custom",
|
|
630
|
-
message: "delete edits cannot include replacement content",
|
|
631
|
-
path: ["content"]
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (edit.content === null || edit.contentHash === null) {
|
|
637
|
-
context.addIssue({
|
|
638
|
-
code: "custom",
|
|
639
|
-
message: "create and update edits require content and contentHash",
|
|
640
|
-
path: ["content"]
|
|
641
|
-
});
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
const expected = contentHash(edit.content);
|
|
645
|
-
if (edit.contentHash !== expected) {
|
|
646
|
-
context.addIssue({
|
|
647
|
-
code: "custom",
|
|
648
|
-
message: `edit contentHash is ${edit.contentHash}; expected ${expected}`,
|
|
649
|
-
path: ["contentHash"]
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
var HarnessWorkspaceRevisionRefSchema = z5.object({
|
|
654
|
-
workspaceId: ReleaseIdSchema,
|
|
655
|
-
revision: RevisionSchema,
|
|
656
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
657
|
-
channelRevision: RevisionSchema
|
|
658
|
-
}).strict();
|
|
659
|
-
var HarnessOverlaySnapshotRefSchema = z5.object({
|
|
660
|
-
id: ReleaseIdSchema,
|
|
661
|
-
revision: RevisionSchema,
|
|
662
|
-
contentHash: ReleaseHashSchema
|
|
663
|
-
}).strict();
|
|
664
|
-
var HarnessTurnSnapshotSchema = z5.object({
|
|
665
|
-
schemaVersion: z5.literal("openpond.harnessTurnSnapshot.v1"),
|
|
666
|
-
workspaceId: ReleaseIdSchema,
|
|
667
|
-
workspaceRevision: RevisionSchema,
|
|
668
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
669
|
-
channelName: ReleaseIdSchema,
|
|
670
|
-
channelRevision: RevisionSchema,
|
|
671
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
672
|
-
toolCatalogHash: ReleaseHashSchema.nullable().optional(),
|
|
673
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable().optional().default(null)
|
|
674
|
-
}).strict();
|
|
675
|
-
var HarnessRunOverlayContentSchema = z5.object({
|
|
676
|
-
schemaVersion: z5.literal("openpond.harnessRunOverlay.v1"),
|
|
677
|
-
id: ReleaseIdSchema,
|
|
678
|
-
runId: ReleaseIdSchema,
|
|
679
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
680
|
-
workspace: HarnessWorkspaceRevisionRefSchema,
|
|
681
|
-
revision: RevisionSchema,
|
|
682
|
-
status: z5.enum(["active", "frozen", "abandoned"]),
|
|
683
|
-
edits: z5.array(HarnessOverlayEditSchema).max(1e3),
|
|
684
|
-
createdAt: ReleaseTimestampSchema,
|
|
685
|
-
updatedAt: ReleaseTimestampSchema,
|
|
686
|
-
metadata: MetadataSchema2
|
|
687
|
-
}).strict();
|
|
688
|
-
var HarnessRunOverlaySchema = HarnessRunOverlayContentSchema.extend({
|
|
689
|
-
contentHash: ReleaseHashSchema
|
|
690
|
-
}).strict();
|
|
691
|
-
var HarnessProposalEvidenceRefSchema = z5.object({
|
|
692
|
-
kind: z5.enum([
|
|
693
|
-
"tool_event",
|
|
694
|
-
"recovery",
|
|
695
|
-
"validation",
|
|
696
|
-
"user_turn",
|
|
697
|
-
"work_output",
|
|
698
|
-
"work_receipt"
|
|
699
|
-
]),
|
|
700
|
-
id: ReleaseIdSchema,
|
|
701
|
-
contentHash: ReleaseHashSchema.nullable()
|
|
702
|
-
}).strict();
|
|
703
|
-
var HarnessValidationPlanItemSchema = z5.object({
|
|
704
|
-
id: ReleaseIdSchema,
|
|
705
|
-
kind: z5.enum([
|
|
706
|
-
"dependency",
|
|
707
|
-
"schema",
|
|
708
|
-
"package",
|
|
709
|
-
"file_render",
|
|
710
|
-
"skill",
|
|
711
|
-
"prompt",
|
|
712
|
-
"business_formula",
|
|
713
|
-
"targeted_evaluation",
|
|
714
|
-
"observed_recovery",
|
|
715
|
-
"memory",
|
|
716
|
-
"component_activation"
|
|
717
|
-
]),
|
|
718
|
-
description: BoundedTextSchema2,
|
|
719
|
-
required: z5.boolean()
|
|
720
|
-
}).strict();
|
|
721
|
-
var HarnessImprovementProposalContentSchema = z5.object({
|
|
722
|
-
schemaVersion: z5.literal("openpond.harnessImprovementProposal.v1"),
|
|
723
|
-
id: ReleaseIdSchema,
|
|
724
|
-
overlay: HarnessOverlaySnapshotRefSchema,
|
|
725
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
726
|
-
expectedWorkspace: HarnessWorkspaceRevisionRefSchema,
|
|
727
|
-
requestedScope: z5.enum(["personal", "team", "global"]),
|
|
728
|
-
route: HarnessImprovementRouteSchema,
|
|
729
|
-
risk: z5.enum(["low", "review", "restricted"]),
|
|
730
|
-
effects: z5.array(HarnessChangeEffectSchema).min(1).max(20),
|
|
731
|
-
evidence: z5.array(HarnessProposalEvidenceRefSchema).min(1).max(1e3),
|
|
732
|
-
edits: z5.array(HarnessOverlayEditSchema).min(1).max(1e3),
|
|
733
|
-
validationPlan: z5.array(HarnessValidationPlanItemSchema).min(1).max(100),
|
|
734
|
-
expectedOutcome: BoundedTextSchema2,
|
|
735
|
-
createdAt: ReleaseTimestampSchema,
|
|
736
|
-
metadata: MetadataSchema2
|
|
737
|
-
}).strict().superRefine((proposal, context) => {
|
|
738
|
-
const declaredEffects = new Set(proposal.effects);
|
|
739
|
-
for (const [index, edit] of proposal.edits.entries()) {
|
|
740
|
-
if (edit.route !== proposal.route) {
|
|
741
|
-
context.addIssue({
|
|
742
|
-
code: "custom",
|
|
743
|
-
message: "every edit route must match the proposal route",
|
|
744
|
-
path: ["edits", index, "route"]
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
for (const effect of edit.effects) {
|
|
748
|
-
if (!declaredEffects.has(effect)) {
|
|
749
|
-
context.addIssue({
|
|
750
|
-
code: "custom",
|
|
751
|
-
message: `edit effect ${effect} is missing from proposal effects`,
|
|
752
|
-
path: ["edits", index, "effects"]
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
if (new Set(proposal.validationPlan.map((item) => item.id)).size !== proposal.validationPlan.length) {
|
|
758
|
-
context.addIssue({
|
|
759
|
-
code: "custom",
|
|
760
|
-
message: "validation plan ids must be unique",
|
|
761
|
-
path: ["validationPlan"]
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
var HarnessImprovementProposalSchema = HarnessImprovementProposalContentSchema.extend({
|
|
766
|
-
contentHash: ReleaseHashSchema
|
|
767
|
-
}).strict();
|
|
768
|
-
var HarnessTargetedValidationReceiptContentSchema = z5.object({
|
|
769
|
-
schemaVersion: z5.literal("openpond.harnessTargetedValidationReceipt.v1"),
|
|
770
|
-
id: ReleaseIdSchema,
|
|
771
|
-
proposal: ImmutableReleaseRefSchema,
|
|
772
|
-
validationId: ReleaseIdSchema,
|
|
773
|
-
kind: HarnessValidationPlanItemSchema.shape.kind,
|
|
774
|
-
status: z5.enum(["passed", "failed", "blocked", "skipped"]),
|
|
775
|
-
summary: BoundedTextSchema2,
|
|
776
|
-
evidenceRefs: z5.array(HarnessProposalEvidenceRefSchema).max(1e3),
|
|
777
|
-
createdAt: ReleaseTimestampSchema,
|
|
778
|
-
metadata: MetadataSchema2
|
|
779
|
-
}).strict();
|
|
780
|
-
var HarnessTargetedValidationReceiptSchema = HarnessTargetedValidationReceiptContentSchema.extend({
|
|
781
|
-
contentHash: ReleaseHashSchema
|
|
782
|
-
}).strict();
|
|
783
|
-
var HarnessAdvanceDecisionSchema = z5.enum([
|
|
784
|
-
"advanced",
|
|
785
|
-
"retained",
|
|
786
|
-
"conflict",
|
|
787
|
-
"rolled_back"
|
|
788
|
-
]);
|
|
789
|
-
var HarnessAdvanceReceiptContentSchema = z5.object({
|
|
790
|
-
schemaVersion: z5.literal("openpond.harnessAdvanceReceipt.v1"),
|
|
791
|
-
id: ReleaseIdSchema,
|
|
792
|
-
workspaceId: ReleaseIdSchema,
|
|
793
|
-
ownerScope: HarnessOwnerScopeSchema,
|
|
794
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
795
|
-
expectedWorkspaceRevision: RevisionSchema,
|
|
796
|
-
observedWorkspaceRevision: RevisionSchema,
|
|
797
|
-
previousChannelRevision: RevisionSchema,
|
|
798
|
-
nextChannelRevision: RevisionSchema,
|
|
799
|
-
previousRelease: ImmutableReleaseRefSchema.nullable(),
|
|
800
|
-
nextRelease: ImmutableReleaseRefSchema.nullable(),
|
|
801
|
-
validationReceipts: z5.array(ImmutableReleaseRefSchema).max(100),
|
|
802
|
-
decision: HarnessAdvanceDecisionSchema,
|
|
803
|
-
reason: BoundedTextSchema2,
|
|
804
|
-
rollbackOf: ImmutableReleaseRefSchema.nullable(),
|
|
805
|
-
createdAt: ReleaseTimestampSchema,
|
|
806
|
-
metadata: MetadataSchema2
|
|
807
|
-
}).strict().superRefine((receipt, context) => {
|
|
808
|
-
const changed = receipt.nextChannelRevision === receipt.previousChannelRevision + 1;
|
|
809
|
-
if (["advanced", "rolled_back"].includes(receipt.decision) !== changed) {
|
|
810
|
-
context.addIssue({
|
|
811
|
-
code: "custom",
|
|
812
|
-
message: "only successful advancement or rollback increments the channel revision",
|
|
813
|
-
path: ["nextChannelRevision"]
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
if (receipt.decision === "rolled_back" && receipt.rollbackOf === null) {
|
|
817
|
-
context.addIssue({
|
|
818
|
-
code: "custom",
|
|
819
|
-
message: "rollback receipts require rollbackOf",
|
|
820
|
-
path: ["rollbackOf"]
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
if (receipt.decision !== "rolled_back" && receipt.rollbackOf !== null) {
|
|
824
|
-
context.addIssue({
|
|
825
|
-
code: "custom",
|
|
826
|
-
message: "rollbackOf is only valid for rollback receipts",
|
|
827
|
-
path: ["rollbackOf"]
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
var HarnessAdvanceReceiptSchema = HarnessAdvanceReceiptContentSchema.extend({
|
|
832
|
-
contentHash: ReleaseHashSchema
|
|
833
|
-
}).strict();
|
|
834
|
-
var HarnessOverlayMergeReceiptContentSchema = z5.object({
|
|
835
|
-
schemaVersion: z5.literal("openpond.harnessOverlayMergeReceipt.v1"),
|
|
836
|
-
id: ReleaseIdSchema,
|
|
837
|
-
workspaceId: ReleaseIdSchema,
|
|
838
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
839
|
-
leftOverlay: HarnessOverlaySnapshotRefSchema,
|
|
840
|
-
rightOverlay: HarnessOverlaySnapshotRefSchema,
|
|
841
|
-
decision: z5.enum(["merged", "conflict"]),
|
|
842
|
-
mergedOverlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
843
|
-
conflictTargets: z5.array(z5.string().trim().min(1).max(2e3)).max(1e3),
|
|
844
|
-
requiresRevalidation: z5.literal(true),
|
|
845
|
-
createdAt: ReleaseTimestampSchema,
|
|
846
|
-
metadata: MetadataSchema2
|
|
847
|
-
}).strict().superRefine((receipt, context) => {
|
|
848
|
-
if (receipt.decision === "merged" !== (receipt.mergedOverlay !== null)) {
|
|
849
|
-
context.addIssue({
|
|
850
|
-
code: "custom",
|
|
851
|
-
message: "merged decisions require a merged overlay; conflicts cannot provide one",
|
|
852
|
-
path: ["mergedOverlay"]
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
if (receipt.decision === "conflict" !== receipt.conflictTargets.length > 0) {
|
|
856
|
-
context.addIssue({
|
|
857
|
-
code: "custom",
|
|
858
|
-
message: "conflict decisions require conflict targets and merged decisions cannot include them",
|
|
859
|
-
path: ["conflictTargets"]
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
var HarnessOverlayMergeReceiptSchema = HarnessOverlayMergeReceiptContentSchema.extend({
|
|
864
|
-
contentHash: ReleaseHashSchema
|
|
865
|
-
}).strict();
|
|
866
|
-
|
|
867
|
-
// ../harness/dist/harness-improvements.js
|
|
868
|
-
var BoundedTextSchema3 = z6.string().trim().min(1).max(1e5);
|
|
869
|
-
var MetadataSchema3 = z6.record(z6.string(), z6.unknown()).default({});
|
|
870
|
-
var ImprovementSafeBoundaryKindSchema = z6.enum([
|
|
871
|
-
"completed_tool_batch",
|
|
872
|
-
"before_model_step",
|
|
873
|
-
"turn_completed",
|
|
874
|
-
"turn_paused"
|
|
875
|
-
]);
|
|
876
|
-
var ImprovementSafeBoundarySchema = z6.object({
|
|
877
|
-
kind: ImprovementSafeBoundaryKindSchema,
|
|
878
|
-
eventSequence: z6.number().int().nonnegative(),
|
|
879
|
-
occurredAt: ReleaseTimestampSchema
|
|
880
|
-
}).strict();
|
|
881
|
-
var ImprovementEventRefSchema = z6.object({
|
|
882
|
-
id: ReleaseIdSchema,
|
|
883
|
-
sequence: z6.number().int().nonnegative().nullable(),
|
|
884
|
-
contentHash: ReleaseHashSchema
|
|
885
|
-
}).strict();
|
|
886
|
-
var ImprovementObservationKindSchema = z6.enum([
|
|
887
|
-
"tool_failure",
|
|
888
|
-
"retry",
|
|
889
|
-
"recovery",
|
|
890
|
-
"validation",
|
|
891
|
-
"user_turn",
|
|
892
|
-
"reusable_success",
|
|
893
|
-
"completion_detour"
|
|
894
|
-
]);
|
|
895
|
-
var ImprovementObservationStateSchema = z6.enum([
|
|
896
|
-
"open",
|
|
897
|
-
"recovered",
|
|
898
|
-
"terminal"
|
|
899
|
-
]);
|
|
900
|
-
var ImprovementToolIdentitySchema = z6.object({
|
|
901
|
-
name: z6.string().trim().min(1).max(500),
|
|
902
|
-
invocationKey: ReleaseHashSchema
|
|
903
|
-
}).strict();
|
|
904
|
-
var ImprovementObservationContentSchema = z6.object({
|
|
905
|
-
schemaVersion: z6.literal("openpond.improvementObservation.v1"),
|
|
906
|
-
id: ReleaseIdSchema,
|
|
907
|
-
runRef: ReleaseIdSchema,
|
|
908
|
-
turnId: ReleaseIdSchema,
|
|
909
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
910
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
911
|
-
eventRefs: z6.array(ImprovementEventRefSchema).min(1).max(100),
|
|
912
|
-
kind: ImprovementObservationKindSchema,
|
|
913
|
-
state: ImprovementObservationStateSchema,
|
|
914
|
-
tool: ImprovementToolIdentitySchema.nullable(),
|
|
915
|
-
deterministicClass: z6.string().trim().min(1).max(500).nullable(),
|
|
916
|
-
summary: BoundedTextSchema3,
|
|
917
|
-
createdAt: ReleaseTimestampSchema,
|
|
918
|
-
metadata: MetadataSchema3
|
|
919
|
-
}).strict().superRefine((observation, context) => {
|
|
920
|
-
if (new Set(observation.eventRefs.map((reference) => reference.id)).size !== observation.eventRefs.length) {
|
|
921
|
-
context.addIssue({
|
|
922
|
-
code: "custom",
|
|
923
|
-
message: "observation event refs must be unique",
|
|
924
|
-
path: ["eventRefs"]
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
if (["tool_failure", "retry", "recovery", "completion_detour"].includes(observation.kind) && observation.tool === null) {
|
|
928
|
-
context.addIssue({
|
|
929
|
-
code: "custom",
|
|
930
|
-
message: `${observation.kind} observations require a tool identity`,
|
|
931
|
-
path: ["tool"]
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
var ImprovementObservationSchema = ImprovementObservationContentSchema.extend({
|
|
936
|
-
contentHash: ReleaseHashSchema
|
|
937
|
-
}).strict();
|
|
938
|
-
var RefinementTriggerPolicySchema = z6.object({
|
|
939
|
-
schemaVersion: z6.literal("openpond.refinementTriggerPolicy.v1"),
|
|
940
|
-
maxEstimatedCostUsd: z6.number().finite().nonnegative(),
|
|
941
|
-
cooldownMs: z6.number().int().nonnegative(),
|
|
942
|
-
maxPendingPlans: z6.number().int().min(1).max(100),
|
|
943
|
-
maxEvidenceEvents: z6.number().int().min(1).max(1e3),
|
|
944
|
-
maxProposalEdits: z6.number().int().min(1).max(1e3),
|
|
945
|
-
maxProposalBytes: z6.number().int().min(1).max(1e7)
|
|
946
|
-
}).strict();
|
|
947
|
-
var RefinementTriggerDecisionKindSchema = z6.enum([
|
|
948
|
-
"no_action",
|
|
949
|
-
"route_deterministically",
|
|
950
|
-
"queue_refiner"
|
|
951
|
-
]);
|
|
952
|
-
var RefinementTriggerDecisionContentSchema = z6.object({
|
|
953
|
-
schemaVersion: z6.literal("openpond.refinementTriggerDecision.v1"),
|
|
954
|
-
id: ReleaseIdSchema,
|
|
955
|
-
runRef: ReleaseIdSchema,
|
|
956
|
-
turnId: ReleaseIdSchema,
|
|
957
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
958
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
959
|
-
observations: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
960
|
-
decision: RefinementTriggerDecisionKindSchema,
|
|
961
|
-
deterministicRoute: HarnessImprovementRouteSchema.nullable(),
|
|
962
|
-
suggestedRoutes: z6.array(HarnessImprovementRouteSchema).max(8),
|
|
963
|
-
reason: BoundedTextSchema3,
|
|
964
|
-
deduplicationKey: ReleaseHashSchema,
|
|
965
|
-
policy: RefinementTriggerPolicySchema,
|
|
966
|
-
estimatedMaxCostUsd: z6.number().finite().nonnegative(),
|
|
967
|
-
pendingPlanCount: z6.number().int().nonnegative(),
|
|
968
|
-
boundary: ImprovementSafeBoundarySchema,
|
|
969
|
-
cooldownUntil: ReleaseTimestampSchema.nullable(),
|
|
970
|
-
createdAt: ReleaseTimestampSchema,
|
|
971
|
-
metadata: MetadataSchema3
|
|
972
|
-
}).strict().superRefine((trigger, context) => {
|
|
973
|
-
if (trigger.estimatedMaxCostUsd > trigger.policy.maxEstimatedCostUsd) {
|
|
974
|
-
context.addIssue({
|
|
975
|
-
code: "custom",
|
|
976
|
-
message: "estimated Refiner cost exceeds the trigger policy budget",
|
|
977
|
-
path: ["estimatedMaxCostUsd"]
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
if (trigger.pendingPlanCount > trigger.policy.maxPendingPlans) {
|
|
981
|
-
context.addIssue({
|
|
982
|
-
code: "custom",
|
|
983
|
-
message: "pending plan count exceeds the trigger policy limit",
|
|
984
|
-
path: ["pendingPlanCount"]
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
if (trigger.observations.length > trigger.policy.maxEvidenceEvents) {
|
|
988
|
-
context.addIssue({
|
|
989
|
-
code: "custom",
|
|
990
|
-
message: "trigger observations exceed the evidence budget",
|
|
991
|
-
path: ["observations"]
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
if (trigger.decision === "route_deterministically" && trigger.deterministicRoute === null) {
|
|
995
|
-
context.addIssue({
|
|
996
|
-
code: "custom",
|
|
997
|
-
message: "deterministic decisions require a route",
|
|
998
|
-
path: ["deterministicRoute"]
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
if (trigger.decision !== "route_deterministically" && trigger.deterministicRoute !== null) {
|
|
1002
|
-
context.addIssue({
|
|
1003
|
-
code: "custom",
|
|
1004
|
-
message: "only deterministic decisions may declare a deterministic route",
|
|
1005
|
-
path: ["deterministicRoute"]
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
if (trigger.decision === "no_action" && trigger.suggestedRoutes.length > 0) {
|
|
1009
|
-
context.addIssue({
|
|
1010
|
-
code: "custom",
|
|
1011
|
-
message: "no-action decisions cannot suggest routes",
|
|
1012
|
-
path: ["suggestedRoutes"]
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
if (trigger.decision !== "no_action" && trigger.observations.length === 0) {
|
|
1016
|
-
context.addIssue({
|
|
1017
|
-
code: "custom",
|
|
1018
|
-
message: "actionable trigger decisions require observations",
|
|
1019
|
-
path: ["observations"]
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
var RefinementTriggerDecisionSchema = RefinementTriggerDecisionContentSchema.extend({
|
|
1024
|
-
contentHash: ReleaseHashSchema
|
|
1025
|
-
}).strict();
|
|
1026
|
-
var ImprovementRouteAuthoritySchema = z6.enum([
|
|
1027
|
-
"runtime_service",
|
|
1028
|
-
"refiner_model",
|
|
1029
|
-
"human_review",
|
|
1030
|
-
"evaluation_system",
|
|
1031
|
-
"training_system"
|
|
1032
|
-
]);
|
|
1033
|
-
var ImprovementRouteDecisionContentSchema = z6.object({
|
|
1034
|
-
schemaVersion: z6.literal("openpond.improvementRouteDecision.v1"),
|
|
1035
|
-
id: ReleaseIdSchema,
|
|
1036
|
-
trigger: ImmutableReleaseRefSchema,
|
|
1037
|
-
route: HarnessImprovementRouteSchema,
|
|
1038
|
-
authority: ImprovementRouteAuthoritySchema,
|
|
1039
|
-
automatic: z6.boolean(),
|
|
1040
|
-
reason: BoundedTextSchema3,
|
|
1041
|
-
createdAt: ReleaseTimestampSchema,
|
|
1042
|
-
metadata: MetadataSchema3
|
|
1043
|
-
}).strict().superRefine((decision, context) => {
|
|
1044
|
-
if (decision.automatic && ["human_review", "evaluation_system", "training_system"].includes(decision.authority)) {
|
|
1045
|
-
context.addIssue({
|
|
1046
|
-
code: "custom",
|
|
1047
|
-
message: `${decision.authority} routes cannot be marked automatic`,
|
|
1048
|
-
path: ["automatic"]
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
if (decision.route === "training" && decision.automatic && decision.authority !== "training_system") {
|
|
1052
|
-
context.addIssue({
|
|
1053
|
-
code: "custom",
|
|
1054
|
-
message: "automatic training routes require training-system authority",
|
|
1055
|
-
path: ["authority"]
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
var ImprovementRouteDecisionSchema = ImprovementRouteDecisionContentSchema.extend({
|
|
1060
|
-
contentHash: ReleaseHashSchema
|
|
1061
|
-
}).strict();
|
|
1062
|
-
var HarnessRefinerOutcomeContentSchema = z6.object({
|
|
1063
|
-
schemaVersion: z6.literal("openpond.harnessRefinerOutcome.v1"),
|
|
1064
|
-
id: ReleaseIdSchema,
|
|
1065
|
-
trigger: ImmutableReleaseRefSchema,
|
|
1066
|
-
decision: z6.enum(["no_action", "proposed"]),
|
|
1067
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
1068
|
-
reason: BoundedTextSchema3,
|
|
1069
|
-
evidenceRefs: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
1070
|
-
estimatedCostUsd: z6.number().finite().nonnegative(),
|
|
1071
|
-
createdAt: ReleaseTimestampSchema,
|
|
1072
|
-
metadata: MetadataSchema3
|
|
1073
|
-
}).strict().superRefine((outcome, context) => {
|
|
1074
|
-
if (outcome.decision === "proposed" !== (outcome.proposal !== null)) {
|
|
1075
|
-
context.addIssue({
|
|
1076
|
-
code: "custom",
|
|
1077
|
-
message: "proposed Refiner outcomes require a proposal; no-action outcomes cannot include one",
|
|
1078
|
-
path: ["proposal"]
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
var HarnessRefinerOutcomeSchema = HarnessRefinerOutcomeContentSchema.extend({
|
|
1083
|
-
contentHash: ReleaseHashSchema
|
|
1084
|
-
}).strict();
|
|
1085
|
-
var ImprovementApplyDecisionSchema = z6.enum([
|
|
1086
|
-
"applied",
|
|
1087
|
-
"retained",
|
|
1088
|
-
"declined",
|
|
1089
|
-
"conflict",
|
|
1090
|
-
"rolled_back"
|
|
1091
|
-
]);
|
|
1092
|
-
var ImprovementApplyReceiptContentSchema = z6.object({
|
|
1093
|
-
schemaVersion: z6.literal("openpond.improvementApplyReceipt.v1"),
|
|
1094
|
-
id: ReleaseIdSchema,
|
|
1095
|
-
proposal: ImmutableReleaseRefSchema,
|
|
1096
|
-
beforeOverlay: HarnessOverlaySnapshotRefSchema,
|
|
1097
|
-
afterOverlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
1098
|
-
decision: ImprovementApplyDecisionSchema,
|
|
1099
|
-
boundary: ImprovementSafeBoundarySchema,
|
|
1100
|
-
validationRefs: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
1101
|
-
outcomeEvidenceRefs: z6.array(ImprovementEventRefSchema).max(1e3),
|
|
1102
|
-
rollbackOf: ImmutableReleaseRefSchema.nullable(),
|
|
1103
|
-
createdAt: ReleaseTimestampSchema,
|
|
1104
|
-
metadata: MetadataSchema3
|
|
1105
|
-
}).strict().superRefine((receipt, context) => {
|
|
1106
|
-
if (receipt.decision === "applied" !== (receipt.afterOverlay !== null)) {
|
|
1107
|
-
context.addIssue({
|
|
1108
|
-
code: "custom",
|
|
1109
|
-
message: "applied receipts require an after-overlay; other decisions cannot include one",
|
|
1110
|
-
path: ["afterOverlay"]
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
if (receipt.decision === "rolled_back" !== (receipt.rollbackOf !== null)) {
|
|
1114
|
-
context.addIssue({
|
|
1115
|
-
code: "custom",
|
|
1116
|
-
message: "only rollback receipts require rollbackOf",
|
|
1117
|
-
path: ["rollbackOf"]
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
});
|
|
1121
|
-
var ImprovementApplyReceiptSchema = ImprovementApplyReceiptContentSchema.extend({
|
|
1122
|
-
contentHash: ReleaseHashSchema
|
|
1123
|
-
}).strict();
|
|
1124
|
-
|
|
1125
|
-
// ../harness/dist/models.js
|
|
1126
|
-
import { z as z7 } from "zod";
|
|
1127
|
-
var ModelRefSchema = z7.object({
|
|
1128
|
-
provider: ReleaseIdSchema,
|
|
1129
|
-
model: ReleaseIdSchema,
|
|
1130
|
-
revision: z7.string().trim().min(1).max(500).nullable().default(null),
|
|
1131
|
-
artifactHash: ReleaseHashSchema.nullable().default(null),
|
|
1132
|
-
tokenizerRevision: z7.string().trim().min(1).max(500).nullable().default(null),
|
|
1133
|
-
chatTemplateHash: ReleaseHashSchema.nullable().default(null)
|
|
1134
|
-
}).strict();
|
|
1135
|
-
|
|
1136
|
-
// ../harness/dist/refiner.js
|
|
1137
|
-
import { z as z9 } from "zod";
|
|
1138
|
-
|
|
1139
|
-
// ../harness/dist/refiner-profiles.js
|
|
1140
|
-
import { z as z8 } from "zod";
|
|
1141
|
-
var RefinerProposalRouteSchema = z8.enum(["memory", "prompt", "skill", "agent"]);
|
|
1142
|
-
var RefinerExternalRouteSchema = z8.enum(["runtime", "product", "taskset", "training"]);
|
|
1143
|
-
var RefinerReviewInstructionSchema = z8.object({
|
|
1144
|
-
id: z8.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
1145
|
-
text: z8.string().trim().min(1).max(1e4)
|
|
1146
|
-
}).strict();
|
|
1147
|
-
var RefinerReviewProfileSchema = z8.object({
|
|
1148
|
-
schemaVersion: z8.literal("openpond.refinerReviewProfile.v1"),
|
|
1149
|
-
id: z8.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
1150
|
-
version: z8.string().trim().min(1).max(120),
|
|
1151
|
-
name: z8.string().trim().min(1).max(200),
|
|
1152
|
-
objective: z8.string().trim().min(1).max(1e4),
|
|
1153
|
-
instructions: z8.array(RefinerReviewInstructionSchema).max(100),
|
|
1154
|
-
allowedProposalRoutes: z8.array(RefinerProposalRouteSchema).max(4),
|
|
1155
|
-
allowedExternalRoutes: z8.array(RefinerExternalRouteSchema).max(4)
|
|
1156
|
-
}).strict().superRefine((profile, context) => {
|
|
1157
|
-
const instructionIds = profile.instructions.map((instruction) => instruction.id);
|
|
1158
|
-
if (new Set(instructionIds).size !== instructionIds.length) {
|
|
1159
|
-
context.addIssue({ code: "custom", message: "instruction IDs must be unique", path: ["instructions"] });
|
|
1160
|
-
}
|
|
1161
|
-
if (new Set(profile.allowedProposalRoutes).size !== profile.allowedProposalRoutes.length) {
|
|
1162
|
-
context.addIssue({ code: "custom", message: "proposal routes must be unique", path: ["allowedProposalRoutes"] });
|
|
1163
|
-
}
|
|
1164
|
-
if (new Set(profile.allowedExternalRoutes).size !== profile.allowedExternalRoutes.length) {
|
|
1165
|
-
context.addIssue({ code: "custom", message: "external routes must be unique", path: ["allowedExternalRoutes"] });
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
var RefinerReleaseSchema = z8.object({
|
|
1169
|
-
schemaVersion: z8.literal("openpond.refinerRelease.v1"),
|
|
1170
|
-
id: z8.string().trim().min(1).max(240),
|
|
1171
|
-
coreVersion: z8.string().trim().min(1).max(120),
|
|
1172
|
-
coreHash: ReleaseHashSchema,
|
|
1173
|
-
profile: RefinerReviewProfileSchema,
|
|
1174
|
-
profileHash: ReleaseHashSchema,
|
|
1175
|
-
composedPromptHash: ReleaseHashSchema,
|
|
1176
|
-
createdAt: ReleaseTimestampSchema,
|
|
1177
|
-
contentHash: ReleaseHashSchema
|
|
1178
|
-
}).strict();
|
|
1179
|
-
var RefinerBindingSchema = z8.object({
|
|
1180
|
-
schemaVersion: z8.literal("openpond.refinerBinding.v1"),
|
|
1181
|
-
channel: z8.literal("active"),
|
|
1182
|
-
revision: z8.number().int().nonnegative(),
|
|
1183
|
-
release: ImmutableReleaseRefSchema,
|
|
1184
|
-
updatedAt: ReleaseTimestampSchema
|
|
1185
|
-
}).strict();
|
|
1186
|
-
var RefinerTransitionReceiptSchema = z8.object({
|
|
1187
|
-
schemaVersion: z8.literal("openpond.refinerTransitionReceipt.v1"),
|
|
1188
|
-
id: z8.string().trim().min(1).max(240),
|
|
1189
|
-
operation: z8.enum(["initialize", "update", "activate", "rollback"]),
|
|
1190
|
-
bindingChanged: z8.boolean(),
|
|
1191
|
-
previousRelease: ImmutableReleaseRefSchema.nullable(),
|
|
1192
|
-
nextRelease: ImmutableReleaseRefSchema,
|
|
1193
|
-
actor: z8.string().trim().min(1).max(240),
|
|
1194
|
-
reason: z8.string().trim().min(1).max(1e4),
|
|
1195
|
-
authoringSkillHash: ReleaseHashSchema.nullable(),
|
|
1196
|
-
validation: z8.object({ valid: z8.boolean(), messages: z8.array(z8.string().max(2e3)).max(100) }).strict(),
|
|
1197
|
-
createdAt: ReleaseTimestampSchema,
|
|
1198
|
-
contentHash: ReleaseHashSchema
|
|
1199
|
-
}).strict();
|
|
1200
|
-
|
|
1201
|
-
// ../harness/dist/refiner.js
|
|
1202
|
-
var RefinerNoActionDecisionSchema = z9.object({
|
|
1203
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
1204
|
-
decision: z9.literal("no_action"),
|
|
1205
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1206
|
-
}).strip();
|
|
1207
|
-
var RefinerExternalRouteDecisionSchema = z9.object({
|
|
1208
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
1209
|
-
decision: z9.literal("route"),
|
|
1210
|
-
route: z9.enum(["runtime", "product", "taskset", "training"]),
|
|
1211
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
1212
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
1213
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1214
|
-
}).strip();
|
|
1215
|
-
var RefinerProposalDecisionSchema = z9.object({
|
|
1216
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
1217
|
-
decision: z9.literal("propose"),
|
|
1218
|
-
route: z9.enum(["memory", "prompt", "skill", "agent"]),
|
|
1219
|
-
operation: z9.enum(["create", "update", "delete"]),
|
|
1220
|
-
target: z9.string().trim().min(1).max(2e3),
|
|
1221
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
1222
|
-
createContent: z9.string().min(1).max(2e4).nullable(),
|
|
1223
|
-
find: z9.string().min(1).max(8e3).nullable(),
|
|
1224
|
-
replace: z9.string().max(8e3).nullable(),
|
|
1225
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
1226
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1227
|
-
}).strip().superRefine((decision, context) => {
|
|
1228
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
1229
|
-
context.addIssue({
|
|
1230
|
-
code: "custom",
|
|
1231
|
-
message: "create proposals require createContent and null find/replace",
|
|
1232
|
-
path: ["createContent"]
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1235
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
1236
|
-
context.addIssue({
|
|
1237
|
-
code: "custom",
|
|
1238
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
1239
|
-
path: ["find"]
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
1243
|
-
context.addIssue({
|
|
1244
|
-
code: "custom",
|
|
1245
|
-
message: "delete proposals require null createContent/find/replace",
|
|
1246
|
-
path: ["createContent"]
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1250
|
-
var LocalHarnessRefinerDecisionSchema = z9.discriminatedUnion("decision", [
|
|
1251
|
-
RefinerNoActionDecisionSchema,
|
|
1252
|
-
RefinerExternalRouteDecisionSchema,
|
|
1253
|
-
RefinerProposalDecisionSchema
|
|
1254
|
-
]);
|
|
1255
|
-
var LocalHarnessRefinerDecisionV1Schema = LocalHarnessRefinerDecisionSchema;
|
|
1256
|
-
var HarnessRefinerEvidenceBasisSchema = z9.object({
|
|
1257
|
-
kind: z9.enum(["single_deterministic", "recurrent_independent"]),
|
|
1258
|
-
supportingEvidenceIds: z9.array(z9.string().trim().min(1).max(2e3)).min(1).max(100),
|
|
1259
|
-
counterevidence: z9.array(z9.string().trim().min(1).max(2e3)).max(20)
|
|
1260
|
-
}).strict().superRefine((basis, context) => {
|
|
1261
|
-
if (new Set(basis.supportingEvidenceIds).size !== basis.supportingEvidenceIds.length) {
|
|
1262
|
-
context.addIssue({
|
|
1263
|
-
code: "custom",
|
|
1264
|
-
message: "supporting evidence IDs must be unique",
|
|
1265
|
-
path: ["supportingEvidenceIds"]
|
|
1266
|
-
});
|
|
1267
|
-
}
|
|
1268
|
-
if (basis.kind === "recurrent_independent" && basis.supportingEvidenceIds.length < 2) {
|
|
1269
|
-
context.addIssue({
|
|
1270
|
-
code: "custom",
|
|
1271
|
-
message: "recurrent independent evidence requires at least two supplied incidents",
|
|
1272
|
-
path: ["supportingEvidenceIds"]
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
});
|
|
1276
|
-
var RefinerNoActionDecisionV2Schema = z9.object({
|
|
1277
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1278
|
-
decision: z9.literal("no_action"),
|
|
1279
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1280
|
-
}).strict();
|
|
1281
|
-
var RefinerExternalRouteDecisionV2Schema = z9.object({
|
|
1282
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1283
|
-
decision: z9.literal("route"),
|
|
1284
|
-
route: z9.enum(["runtime", "product", "taskset", "training"]),
|
|
1285
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
1286
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
1287
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
1288
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1289
|
-
}).strict();
|
|
1290
|
-
var RefinerProposalDecisionV2Schema = z9.object({
|
|
1291
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1292
|
-
decision: z9.literal("propose"),
|
|
1293
|
-
route: z9.enum(["memory", "prompt", "skill", "agent"]),
|
|
1294
|
-
operation: z9.enum(["create", "update", "delete"]),
|
|
1295
|
-
target: z9.string().trim().min(1).max(2e3),
|
|
1296
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
1297
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
1298
|
-
createContent: z9.string().min(1).max(2e4).nullable(),
|
|
1299
|
-
find: z9.string().min(1).max(8e3).nullable(),
|
|
1300
|
-
replace: z9.string().max(8e3).nullable(),
|
|
1301
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
1302
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
1303
|
-
}).strict().superRefine((decision, context) => {
|
|
1304
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
1305
|
-
context.addIssue({
|
|
1306
|
-
code: "custom",
|
|
1307
|
-
message: "create proposals require createContent and null find/replace",
|
|
1308
|
-
path: ["createContent"]
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
1312
|
-
context.addIssue({
|
|
1313
|
-
code: "custom",
|
|
1314
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
1315
|
-
path: ["find"]
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
1319
|
-
context.addIssue({
|
|
1320
|
-
code: "custom",
|
|
1321
|
-
message: "delete proposals require null createContent/find/replace",
|
|
1322
|
-
path: ["createContent"]
|
|
1323
|
-
});
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
var LocalHarnessRefinerDecisionV2Schema = z9.discriminatedUnion("decision", [
|
|
1327
|
-
RefinerNoActionDecisionV2Schema,
|
|
1328
|
-
RefinerExternalRouteDecisionV2Schema,
|
|
1329
|
-
RefinerProposalDecisionV2Schema
|
|
1330
|
-
]);
|
|
1331
|
-
var LocalHarnessRefinerDecisionAnySchema = z9.union([
|
|
1332
|
-
LocalHarnessRefinerDecisionV1Schema,
|
|
1333
|
-
LocalHarnessRefinerDecisionV2Schema
|
|
1334
|
-
]);
|
|
1335
|
-
var HarnessRefinerCapabilitiesSchema = z9.object({
|
|
1336
|
-
memory: z9.boolean(),
|
|
1337
|
-
prompt: z9.boolean(),
|
|
1338
|
-
skill: z9.boolean(),
|
|
1339
|
-
agent: z9.boolean()
|
|
1340
|
-
}).strict();
|
|
1341
|
-
var SourceKindSchema = z9.enum(["memory", "instruction", "skill", "agent"]);
|
|
1342
|
-
var RefinerSourceFileSchema = z9.object({
|
|
1343
|
-
path: z9.string().trim().min(1).max(2e3),
|
|
1344
|
-
kind: SourceKindSchema,
|
|
1345
|
-
content: z9.string().max(6e4),
|
|
1346
|
-
loaded: z9.boolean()
|
|
1347
|
-
}).strict();
|
|
1348
|
-
var RefinerSourceCatalogEntrySchema = z9.object({
|
|
1349
|
-
path: z9.string().trim().min(1).max(2e3),
|
|
1350
|
-
kind: SourceKindSchema,
|
|
1351
|
-
loaded: z9.boolean()
|
|
1352
|
-
}).strict();
|
|
1353
|
-
var LocalHarnessRefinerEvidenceSchema = z9.object({
|
|
1354
|
-
capabilities: HarnessRefinerCapabilitiesSchema,
|
|
1355
|
-
trigger: z9.record(z9.string(), z9.unknown()),
|
|
1356
|
-
observations: z9.array(z9.record(z9.string(), z9.unknown())).max(20),
|
|
1357
|
-
admissibleEvidenceIds: z9.array(z9.string().trim().min(1).max(2e3)).max(1e4),
|
|
1358
|
-
reviewPacket: z9.object({
|
|
1359
|
-
currentTurn: z9.object({
|
|
1360
|
-
id: z9.string().trim().min(1).max(2e3),
|
|
1361
|
-
status: z9.string().trim().min(1).max(100).nullable(),
|
|
1362
|
-
error: z9.string().max(2100).nullable(),
|
|
1363
|
-
prompt: z9.string().max(8100).nullable(),
|
|
1364
|
-
assistantOutput: z9.string().max(8100).nullable(),
|
|
1365
|
-
assistantOutputLinkCount: z9.number().int().nonnegative()
|
|
1366
|
-
}).strict(),
|
|
1367
|
-
priorConversation: z9.array(z9.object({
|
|
1368
|
-
turnId: z9.string().trim().min(1).max(2e3),
|
|
1369
|
-
status: z9.string().trim().min(1).max(100).nullable(),
|
|
1370
|
-
prompt: z9.string().max(3100).nullable(),
|
|
1371
|
-
assistantOutput: z9.string().max(3100).nullable()
|
|
1372
|
-
}).strict()).max(3),
|
|
1373
|
-
timeline: z9.array(z9.record(z9.string(), z9.unknown())).max(60),
|
|
1374
|
-
artifacts: z9.array(z9.record(z9.string(), z9.unknown())).max(30),
|
|
1375
|
-
artifactDiagnostics: z9.array(z9.record(z9.string(), z9.unknown())).max(20),
|
|
1376
|
-
executionProfile: z9.object({
|
|
1377
|
-
modelRequestCount: z9.number().int().nonnegative(),
|
|
1378
|
-
failedModelRequestCount: z9.number().int().nonnegative(),
|
|
1379
|
-
promptTokens: z9.number().int().nonnegative(),
|
|
1380
|
-
completionTokens: z9.number().int().nonnegative(),
|
|
1381
|
-
totalTokens: z9.number().int().nonnegative(),
|
|
1382
|
-
toolFailureCount: z9.number().int().nonnegative(),
|
|
1383
|
-
retryCount: z9.number().int().nonnegative(),
|
|
1384
|
-
recoveryCount: z9.number().int().nonnegative()
|
|
1385
|
-
}).strict(),
|
|
1386
|
-
priorIncidents: z9.array(z9.record(z9.string(), z9.unknown())).max(3),
|
|
1387
|
-
truncation: z9.object({
|
|
1388
|
-
timelineEventCount: z9.number().int().nonnegative(),
|
|
1389
|
-
includedTimelineEventCount: z9.number().int().nonnegative(),
|
|
1390
|
-
timelineTruncated: z9.boolean()
|
|
1391
|
-
}).strict()
|
|
1392
|
-
}).strict(),
|
|
1393
|
-
runtimeActivation: z9.object({
|
|
1394
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1395
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1396
|
-
rebasedOntoCurrent: z9.boolean(),
|
|
1397
|
-
admittedSourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
1398
|
-
admittedSourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3)
|
|
1399
|
-
}).strict(),
|
|
1400
|
-
sourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
1401
|
-
sourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3),
|
|
1402
|
-
additionalEvidence: z9.unknown().nullable().optional()
|
|
1403
|
-
}).strict();
|
|
1404
|
-
var OverlayRefSchema = z9.object({
|
|
1405
|
-
id: z9.string().trim().min(1).max(240),
|
|
1406
|
-
revision: z9.number().int().nonnegative(),
|
|
1407
|
-
contentHash: ReleaseHashSchema
|
|
1408
|
-
}).strict();
|
|
1409
|
-
var HostedHarnessRefinerRequestSchema = z9.object({
|
|
1410
|
-
schemaVersion: z9.literal("openpond.hostedHarnessRefinerRequest.v2"),
|
|
1411
|
-
requestId: z9.string().trim().min(1).max(240),
|
|
1412
|
-
idempotencyKey: z9.string().trim().min(1).max(240),
|
|
1413
|
-
evidenceHash: ReleaseHashSchema,
|
|
1414
|
-
harness: z9.object({
|
|
1415
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1416
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1417
|
-
overlay: OverlayRefSchema,
|
|
1418
|
-
workspace: z9.object({
|
|
1419
|
-
id: z9.string().trim().min(1).max(240),
|
|
1420
|
-
revision: z9.number().int().nonnegative(),
|
|
1421
|
-
sourceRevision: ReleaseHashSchema,
|
|
1422
|
-
channelRevision: z9.number().int().nonnegative()
|
|
1423
|
-
}).strict(),
|
|
1424
|
-
capabilities: HarnessRefinerCapabilitiesSchema
|
|
1425
|
-
}).strict(),
|
|
1426
|
-
evidence: LocalHarnessRefinerEvidenceSchema
|
|
1427
|
-
}).strict();
|
|
1428
|
-
var HostedHarnessRefinerUsageSchema = z9.object({
|
|
1429
|
-
promptTokens: z9.number().int().nonnegative(),
|
|
1430
|
-
completionTokens: z9.number().int().nonnegative(),
|
|
1431
|
-
totalTokens: z9.number().int().nonnegative()
|
|
1432
|
-
}).strict();
|
|
1433
|
-
var HostedHarnessRefinerResponseSchema = z9.object({
|
|
1434
|
-
schemaVersion: z9.literal("openpond.hostedHarnessRefinerResponse.v2"),
|
|
1435
|
-
requestId: z9.string().trim().min(1).max(240),
|
|
1436
|
-
evidenceHash: ReleaseHashSchema,
|
|
1437
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1438
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1439
|
-
decision: LocalHarnessRefinerDecisionV2Schema,
|
|
1440
|
-
serviceRevision: z9.string().trim().min(1).max(240),
|
|
1441
|
-
usage: HostedHarnessRefinerUsageSchema
|
|
1442
|
-
}).strict();
|
|
1443
|
-
|
|
1444
|
-
// ../harness/dist/refinement-lifecycle.js
|
|
1445
|
-
import { z as z10 } from "zod";
|
|
1446
|
-
var ShortTextSchema = z10.string().trim().min(1).max(2e3);
|
|
1447
|
-
var BoundedTextSchema4 = z10.string().trim().min(1).max(1e5);
|
|
1448
|
-
var HarnessRefinerOperationSchema = z10.enum(["create", "update", "delete"]);
|
|
1449
|
-
var HarnessRefinerInternalRouteSchema = z10.enum([
|
|
1450
|
-
"memory",
|
|
1451
|
-
"prompt",
|
|
1452
|
-
"skill",
|
|
1453
|
-
"agent"
|
|
1454
|
-
]);
|
|
1455
|
-
var HarnessRefinerExternalRouteSchema = z10.enum([
|
|
1456
|
-
"runtime",
|
|
1457
|
-
"product",
|
|
1458
|
-
"taskset",
|
|
1459
|
-
"training"
|
|
1460
|
-
]);
|
|
1461
|
-
var HarnessRefinerActivityResultSchema = z10.enum([
|
|
1462
|
-
"no_action",
|
|
1463
|
-
"routed",
|
|
1464
|
-
"applied",
|
|
1465
|
-
"retained",
|
|
1466
|
-
"failed"
|
|
1467
|
-
]);
|
|
1468
|
-
var HarnessRefinerCritiqueStatusSchema = z10.enum([
|
|
1469
|
-
"not_applicable",
|
|
1470
|
-
"pending",
|
|
1471
|
-
"passed",
|
|
1472
|
-
"rejected",
|
|
1473
|
-
"failed"
|
|
1474
|
-
]);
|
|
1475
|
-
var HarnessRefinerValidationStatusSchema = z10.enum([
|
|
1476
|
-
"not_applicable",
|
|
1477
|
-
"pending",
|
|
1478
|
-
"passed",
|
|
1479
|
-
"failed"
|
|
1480
|
-
]);
|
|
1481
|
-
var HarnessRefinerActivityReceiptContentSchema = z10.object({
|
|
1482
|
-
schemaVersion: z10.literal("openpond.harnessRefinerActivityReceipt.v1"),
|
|
1483
|
-
id: ReleaseIdSchema,
|
|
1484
|
-
runRef: ReleaseIdSchema,
|
|
1485
|
-
turnId: ReleaseIdSchema,
|
|
1486
|
-
result: HarnessRefinerActivityResultSchema,
|
|
1487
|
-
decision: z10.enum(["no_action", "route", "propose"]).nullable(),
|
|
1488
|
-
route: HarnessImprovementRouteSchema.nullable(),
|
|
1489
|
-
operation: HarnessRefinerOperationSchema.nullable(),
|
|
1490
|
-
target: z10.string().trim().min(1).max(2e3).nullable(),
|
|
1491
|
-
summary: ShortTextSchema,
|
|
1492
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema.nullable(),
|
|
1493
|
-
critiqueStatus: HarnessRefinerCritiqueStatusSchema,
|
|
1494
|
-
validationStatus: HarnessRefinerValidationStatusSchema,
|
|
1495
|
-
trigger: ImmutableReleaseRefSchema,
|
|
1496
|
-
outcome: ImmutableReleaseRefSchema.nullable(),
|
|
1497
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
1498
|
-
applyReceipt: ImmutableReleaseRefSchema.nullable(),
|
|
1499
|
-
inputHarness: ImmutableReleaseRefSchema,
|
|
1500
|
-
outputHarness: ImmutableReleaseRefSchema.nullable(),
|
|
1501
|
-
createdAt: ReleaseTimestampSchema
|
|
1502
|
-
}).strict().superRefine((receipt, context) => {
|
|
1503
|
-
const proposalResult = receipt.result === "applied" || receipt.result === "retained";
|
|
1504
|
-
if (receipt.result === "no_action") {
|
|
1505
|
-
requireFields(context, receipt, {
|
|
1506
|
-
decision: "no_action",
|
|
1507
|
-
route: null,
|
|
1508
|
-
operation: null,
|
|
1509
|
-
target: null,
|
|
1510
|
-
evidenceBasis: null,
|
|
1511
|
-
proposal: null,
|
|
1512
|
-
applyReceipt: null,
|
|
1513
|
-
outputHarness: null,
|
|
1514
|
-
critiqueStatus: "not_applicable",
|
|
1515
|
-
validationStatus: "not_applicable"
|
|
1516
|
-
});
|
|
1517
|
-
} else if (receipt.result === "routed") {
|
|
1518
|
-
if (receipt.decision !== "route" || !HarnessRefinerExternalRouteSchema.safeParse(receipt.route).success || receipt.operation !== null || receipt.target !== null || receipt.evidenceBasis === null || receipt.proposal !== null || receipt.applyReceipt !== null || receipt.outputHarness !== null) {
|
|
1519
|
-
context.addIssue({
|
|
1520
|
-
code: "custom",
|
|
1521
|
-
message: "routed activity requires an external route and evidence basis without proposal state"
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
requireFields(context, receipt, {
|
|
1525
|
-
critiqueStatus: "not_applicable",
|
|
1526
|
-
validationStatus: "not_applicable"
|
|
1527
|
-
});
|
|
1528
|
-
} else if (proposalResult) {
|
|
1529
|
-
if (receipt.decision !== "propose" || !HarnessRefinerInternalRouteSchema.safeParse(receipt.route).success || receipt.operation === null || receipt.target === null || receipt.evidenceBasis === null || receipt.proposal === null || receipt.applyReceipt === null) {
|
|
1530
|
-
context.addIssue({
|
|
1531
|
-
code: "custom",
|
|
1532
|
-
message: "applied and retained activity requires complete proposal state"
|
|
1533
|
-
});
|
|
1534
|
-
}
|
|
1535
|
-
if (receipt.result === "applied" && receipt.outputHarness === null) {
|
|
1536
|
-
context.addIssue({
|
|
1537
|
-
code: "custom",
|
|
1538
|
-
message: "applied activity requires the advanced Harness release",
|
|
1539
|
-
path: ["outputHarness"]
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
if (receipt.result === "applied" && (receipt.critiqueStatus !== "passed" || receipt.validationStatus !== "passed")) {
|
|
1543
|
-
context.addIssue({
|
|
1544
|
-
code: "custom",
|
|
1545
|
-
message: "applied activity requires passed critique and validation"
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
if (receipt.result === "retained" && receipt.outputHarness !== null) {
|
|
1549
|
-
context.addIssue({
|
|
1550
|
-
code: "custom",
|
|
1551
|
-
message: "retained activity cannot report a new Harness release",
|
|
1552
|
-
path: ["outputHarness"]
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
|
-
} else if (receipt.decision !== null || receipt.route !== null || receipt.operation !== null || receipt.target !== null || receipt.evidenceBasis !== null || receipt.outcome !== null || receipt.proposal !== null || receipt.applyReceipt !== null || receipt.outputHarness !== null) {
|
|
1556
|
-
context.addIssue({
|
|
1557
|
-
code: "custom",
|
|
1558
|
-
message: "failed activity cannot claim a decision, route, proposal, or release transition"
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
if (receipt.result !== "failed" && receipt.outcome === null) {
|
|
1562
|
-
context.addIssue({
|
|
1563
|
-
code: "custom",
|
|
1564
|
-
message: "terminal Refiner decisions require an outcome reference",
|
|
1565
|
-
path: ["outcome"]
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
|
-
var HarnessRefinerActivityReceiptSchema = HarnessRefinerActivityReceiptContentSchema.extend({
|
|
1570
|
-
contentHash: ReleaseHashSchema
|
|
1571
|
-
}).strict();
|
|
1572
|
-
var HarnessRefinementCandidateStatusSchema = z10.enum([
|
|
1573
|
-
"unresolved",
|
|
1574
|
-
"confirmed",
|
|
1575
|
-
"resolved",
|
|
1576
|
-
"rejected",
|
|
1577
|
-
"expired"
|
|
1578
|
-
]);
|
|
1579
|
-
var HarnessRefinementCandidateResolutionSchema = z10.object({
|
|
1580
|
-
kind: z10.enum([
|
|
1581
|
-
"applied_change",
|
|
1582
|
-
"later_success",
|
|
1583
|
-
"manual_rejection",
|
|
1584
|
-
"source_revoked",
|
|
1585
|
-
"expired"
|
|
1586
|
-
]),
|
|
1587
|
-
reason: BoundedTextSchema4,
|
|
1588
|
-
evidenceRefs: z10.array(ImmutableReleaseRefSchema).max(1e3),
|
|
1589
|
-
resolvedAt: ReleaseTimestampSchema
|
|
1590
|
-
}).strict();
|
|
1591
|
-
var HarnessRefinementCandidateContentSchema = z10.object({
|
|
1592
|
-
schemaVersion: z10.literal("openpond.harnessRefinementCandidate.v1"),
|
|
1593
|
-
id: ReleaseIdSchema,
|
|
1594
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
1595
|
-
workspaceRef: ReleaseIdSchema,
|
|
1596
|
-
fingerprint: ReleaseHashSchema,
|
|
1597
|
-
recurrenceFamily: z10.string().trim().min(1).max(1e3),
|
|
1598
|
-
statement: BoundedTextSchema4,
|
|
1599
|
-
status: HarnessRefinementCandidateStatusSchema,
|
|
1600
|
-
occurrences: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
1601
|
-
counterevidence: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
1602
|
-
sourceReviews: z10.array(ImmutableReleaseRefSchema).min(1).max(100),
|
|
1603
|
-
relatedHarnessReleases: z10.array(ImmutableReleaseRefSchema).max(100),
|
|
1604
|
-
firstSeenAt: ReleaseTimestampSchema,
|
|
1605
|
-
lastSeenAt: ReleaseTimestampSchema,
|
|
1606
|
-
lastReviewedAt: ReleaseTimestampSchema,
|
|
1607
|
-
expiresAt: ReleaseTimestampSchema,
|
|
1608
|
-
resolution: HarnessRefinementCandidateResolutionSchema.nullable(),
|
|
1609
|
-
createdAt: ReleaseTimestampSchema,
|
|
1610
|
-
updatedAt: ReleaseTimestampSchema
|
|
1611
|
-
}).strict().superRefine((candidate, context) => {
|
|
1612
|
-
requireUniqueRefs(context, candidate.occurrences, "occurrences");
|
|
1613
|
-
requireUniqueRefs(context, candidate.counterevidence, "counterevidence");
|
|
1614
|
-
requireUniqueRefs(context, candidate.sourceReviews, "sourceReviews");
|
|
1615
|
-
requireUniqueRefs(context, candidate.relatedHarnessReleases, "relatedHarnessReleases");
|
|
1616
|
-
const supportingKeys = new Set(candidate.occurrences.map((item) => item.occurrenceKey));
|
|
1617
|
-
if (candidate.counterevidence.some((item) => supportingKeys.has(item.occurrenceKey))) {
|
|
1618
|
-
context.addIssue({
|
|
1619
|
-
code: "custom",
|
|
1620
|
-
message: "supporting occurrences and counterevidence must be disjoint",
|
|
1621
|
-
path: ["counterevidence"]
|
|
1622
|
-
});
|
|
1623
|
-
}
|
|
1624
|
-
const actionable = candidate.status === "unresolved" || candidate.status === "confirmed";
|
|
1625
|
-
if (actionable && candidate.occurrences.length === 0) {
|
|
1626
|
-
context.addIssue({
|
|
1627
|
-
code: "custom",
|
|
1628
|
-
message: "actionable candidates require at least one supporting occurrence",
|
|
1629
|
-
path: ["occurrences"]
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
if (actionable && [...candidate.occurrences, ...candidate.counterevidence].some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
1633
|
-
context.addIssue({
|
|
1634
|
-
code: "custom",
|
|
1635
|
-
message: "actionable candidates may contain only currently authorized evidence",
|
|
1636
|
-
path: ["occurrences"]
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
if (actionable !== (candidate.resolution === null)) {
|
|
1640
|
-
context.addIssue({
|
|
1641
|
-
code: "custom",
|
|
1642
|
-
message: "only resolved, rejected, or expired candidates require a resolution",
|
|
1643
|
-
path: ["resolution"]
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
if (candidate.status === "expired" && candidate.resolution?.kind !== "expired") {
|
|
1647
|
-
context.addIssue({
|
|
1648
|
-
code: "custom",
|
|
1649
|
-
message: "expired candidates require an expired resolution",
|
|
1650
|
-
path: ["resolution", "kind"]
|
|
1651
|
-
});
|
|
1652
|
-
}
|
|
1653
|
-
if (candidate.status === "rejected" && candidate.resolution && !["manual_rejection", "source_revoked"].includes(candidate.resolution.kind)) {
|
|
1654
|
-
context.addIssue({
|
|
1655
|
-
code: "custom",
|
|
1656
|
-
message: "rejected candidates require a rejection or revocation resolution",
|
|
1657
|
-
path: ["resolution", "kind"]
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
if (candidate.status === "resolved" && candidate.resolution && !["applied_change", "later_success"].includes(candidate.resolution.kind)) {
|
|
1661
|
-
context.addIssue({
|
|
1662
|
-
code: "custom",
|
|
1663
|
-
message: "resolved candidates require applied-change or later-success evidence",
|
|
1664
|
-
path: ["resolution", "kind"]
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
requireChronology(context, candidate);
|
|
1668
|
-
});
|
|
1669
|
-
var HarnessRefinementCandidateSchema = HarnessRefinementCandidateContentSchema.extend({
|
|
1670
|
-
contentHash: ReleaseHashSchema
|
|
1671
|
-
}).strict();
|
|
1672
|
-
var HarnessRefinementCandidateLifecycleDecisionSchema = z10.enum([
|
|
1673
|
-
"created",
|
|
1674
|
-
"merged",
|
|
1675
|
-
"rejected",
|
|
1676
|
-
"expired",
|
|
1677
|
-
"reopened",
|
|
1678
|
-
"resolved"
|
|
1679
|
-
]);
|
|
1680
|
-
var HarnessRefinementCandidateLifecycleReceiptContentSchema = z10.object({
|
|
1681
|
-
schemaVersion: z10.literal("openpond.harnessRefinementCandidateLifecycleReceipt.v1"),
|
|
1682
|
-
id: ReleaseIdSchema,
|
|
1683
|
-
candidateId: ReleaseIdSchema,
|
|
1684
|
-
decision: HarnessRefinementCandidateLifecycleDecisionSchema,
|
|
1685
|
-
beforeCandidate: ImmutableReleaseRefSchema.nullable(),
|
|
1686
|
-
afterCandidate: ImmutableReleaseRefSchema,
|
|
1687
|
-
review: ImmutableReleaseRefSchema,
|
|
1688
|
-
addedEvidence: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
1689
|
-
removedEvidence: z10.array(ImmutableReleaseRefSchema).max(1e3),
|
|
1690
|
-
reason: BoundedTextSchema4,
|
|
1691
|
-
createdAt: ReleaseTimestampSchema
|
|
1692
|
-
}).strict().superRefine((receipt, context) => {
|
|
1693
|
-
if (receipt.decision === "created" !== (receipt.beforeCandidate === null)) {
|
|
1694
|
-
context.addIssue({
|
|
1695
|
-
code: "custom",
|
|
1696
|
-
message: "only candidate creation omits the previous candidate reference",
|
|
1697
|
-
path: ["beforeCandidate"]
|
|
1698
|
-
});
|
|
1699
|
-
}
|
|
1700
|
-
if (receipt.beforeCandidate && receipt.beforeCandidate.contentHash === receipt.afterCandidate.contentHash) {
|
|
1701
|
-
context.addIssue({
|
|
1702
|
-
code: "custom",
|
|
1703
|
-
message: "candidate lifecycle transitions must change candidate content",
|
|
1704
|
-
path: ["afterCandidate"]
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
if (["created", "reopened"].includes(receipt.decision) && receipt.addedEvidence.length === 0) {
|
|
1708
|
-
context.addIssue({
|
|
1709
|
-
code: "custom",
|
|
1710
|
-
message: `${receipt.decision} candidate transitions require added evidence`,
|
|
1711
|
-
path: ["addedEvidence"]
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
if (receipt.addedEvidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
1715
|
-
context.addIssue({
|
|
1716
|
-
code: "custom",
|
|
1717
|
-
message: "candidate transitions may add only authorized evidence",
|
|
1718
|
-
path: ["addedEvidence"]
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
requireUniqueRefs(context, receipt.addedEvidence, "addedEvidence");
|
|
1722
|
-
requireUniqueRefs(context, receipt.removedEvidence, "removedEvidence");
|
|
1723
|
-
const removedKeys = new Set(receipt.removedEvidence.map((item) => refKey(item)));
|
|
1724
|
-
if (receipt.addedEvidence.some((item) => removedKeys.has(refKey(item.evidence)))) {
|
|
1725
|
-
context.addIssue({
|
|
1726
|
-
code: "custom",
|
|
1727
|
-
message: "candidate lifecycle evidence cannot be added and removed together",
|
|
1728
|
-
path: ["removedEvidence"]
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1732
|
-
var HarnessRefinementCandidateLifecycleReceiptSchema = HarnessRefinementCandidateLifecycleReceiptContentSchema.extend({
|
|
1733
|
-
contentHash: ReleaseHashSchema
|
|
1734
|
-
}).strict();
|
|
1735
|
-
var HarnessCrossRunRefinementRequestContentSchema = z10.object({
|
|
1736
|
-
schemaVersion: z10.literal("openpond.harnessCrossRunRefinementRequest.v1"),
|
|
1737
|
-
id: ReleaseIdSchema,
|
|
1738
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
1739
|
-
workspaceRef: ReleaseIdSchema,
|
|
1740
|
-
candidate: ImmutableReleaseRefSchema,
|
|
1741
|
-
candidateFingerprint: ReleaseHashSchema,
|
|
1742
|
-
review: ImmutableReleaseRefSchema,
|
|
1743
|
-
admittedHarness: ImmutableReleaseRefSchema,
|
|
1744
|
-
evidence: z10.array(HarnessReviewEvidenceRefSchema).min(1).max(1e3),
|
|
1745
|
-
capabilities: HarnessRefinerCapabilitiesSchema,
|
|
1746
|
-
deduplicationKey: ReleaseHashSchema,
|
|
1747
|
-
createdAt: ReleaseTimestampSchema
|
|
1748
|
-
}).strict().superRefine((request, context) => {
|
|
1749
|
-
if (request.evidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
1750
|
-
context.addIssue({
|
|
1751
|
-
code: "custom",
|
|
1752
|
-
message: "cross-run refinement requires currently authorized evidence",
|
|
1753
|
-
path: ["evidence"]
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
requireUniqueRefs(context, request.evidence, "evidence");
|
|
1757
|
-
if (!Object.values(request.capabilities).some(Boolean)) {
|
|
1758
|
-
context.addIssue({
|
|
1759
|
-
code: "custom",
|
|
1760
|
-
message: "cross-run refinement requires at least one available Harness capability",
|
|
1761
|
-
path: ["capabilities"]
|
|
1762
|
-
});
|
|
1763
|
-
}
|
|
1764
|
-
const expected = harnessCrossRunRefinementDeduplicationKey(request);
|
|
1765
|
-
if (request.deduplicationKey !== expected) {
|
|
1766
|
-
context.addIssue({
|
|
1767
|
-
code: "custom",
|
|
1768
|
-
message: `cross-run refinement deduplicationKey is ${request.deduplicationKey}; expected ${expected}`,
|
|
1769
|
-
path: ["deduplicationKey"]
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
});
|
|
1773
|
-
var HarnessCrossRunRefinementRequestSchema = HarnessCrossRunRefinementRequestContentSchema.extend({
|
|
1774
|
-
contentHash: ReleaseHashSchema
|
|
1775
|
-
}).strict();
|
|
1776
|
-
function harnessCrossRunRefinementDeduplicationKey(input) {
|
|
1777
|
-
return contentHash({
|
|
1778
|
-
schemaVersion: "openpond.harnessCrossRunRefinementIdentity.v1",
|
|
1779
|
-
workspaceRef: input.workspaceRef,
|
|
1780
|
-
candidateFingerprint: input.candidateFingerprint,
|
|
1781
|
-
admittedHarness: input.admittedHarness
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
function requireFields(context, value, expected) {
|
|
1785
|
-
for (const [key, expectedValue] of Object.entries(expected)) {
|
|
1786
|
-
if (value[key] === expectedValue)
|
|
1787
|
-
continue;
|
|
1788
|
-
context.addIssue({
|
|
1789
|
-
code: "custom",
|
|
1790
|
-
message: `${key} must be ${String(expectedValue)}`,
|
|
1791
|
-
path: [key]
|
|
1792
|
-
});
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
function requireUniqueRefs(context, values, path) {
|
|
1796
|
-
const keys = values.map((value) => refKey(value));
|
|
1797
|
-
if (new Set(keys).size === keys.length)
|
|
1798
|
-
return;
|
|
1799
|
-
context.addIssue({
|
|
1800
|
-
code: "custom",
|
|
1801
|
-
message: `${path} references must be unique`,
|
|
1802
|
-
path: [path]
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
function refKey(value) {
|
|
1806
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
1807
|
-
return String(value);
|
|
1808
|
-
const record = value;
|
|
1809
|
-
if (typeof record.occurrenceKey === "string")
|
|
1810
|
-
return record.occurrenceKey;
|
|
1811
|
-
const nested = record.evidence;
|
|
1812
|
-
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
1813
|
-
const evidence = nested;
|
|
1814
|
-
return `${String(evidence.id)}:${String(evidence.contentHash)}`;
|
|
1815
|
-
}
|
|
1816
|
-
return `${String(record.id)}:${String(record.contentHash)}`;
|
|
1817
|
-
}
|
|
1818
|
-
function requireChronology(context, candidate) {
|
|
1819
|
-
const chronology = [
|
|
1820
|
-
["firstSeenAt", candidate.firstSeenAt],
|
|
1821
|
-
["lastSeenAt", candidate.lastSeenAt],
|
|
1822
|
-
["lastReviewedAt", candidate.lastReviewedAt],
|
|
1823
|
-
["updatedAt", candidate.updatedAt],
|
|
1824
|
-
["expiresAt", candidate.expiresAt]
|
|
1825
|
-
];
|
|
1826
|
-
for (let index = 1; index < chronology.length; index += 1) {
|
|
1827
|
-
const previous = chronology[index - 1];
|
|
1828
|
-
const current = chronology[index];
|
|
1829
|
-
if (Date.parse(previous[1]) <= Date.parse(current[1]))
|
|
1830
|
-
continue;
|
|
1831
|
-
context.addIssue({
|
|
1832
|
-
code: "custom",
|
|
1833
|
-
message: `${current[0]} must not precede ${previous[0]}`,
|
|
1834
|
-
path: [current[0]]
|
|
1835
|
-
});
|
|
1836
|
-
}
|
|
1837
|
-
if (Date.parse(candidate.createdAt) > Date.parse(candidate.updatedAt)) {
|
|
1838
|
-
context.addIssue({
|
|
1839
|
-
code: "custom",
|
|
1840
|
-
message: "updatedAt must not precede createdAt",
|
|
1841
|
-
path: ["updatedAt"]
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
// src/taskset-package-contracts.ts
|
|
1847
|
-
import { EnvironmentReleaseSchema as EnvironmentReleaseSchema3, VerifierSetReleaseSchema as VerifierSetReleaseSchema3, verifyEnvironmentRelease as verifyEnvironmentRelease3, verifyVerifierSetRelease as verifyVerifierSetRelease3 } from "@openpond/evals";
|
|
1848
|
-
import { assertTasksetRelease as assertTasksetRelease2, TasksetReleaseSchema as TasksetReleaseSchema2 } from "@openpond/evals/tasksets";
|
|
1849
|
-
import { assertBoundedTaskJson as assertBoundedTaskJson3 } from "@openpond/evals/task-schema";
|
|
1850
|
-
|
|
1851
|
-
// src/model-taskset-derivation.ts
|
|
1852
|
-
import { z as z14 } from "zod";
|
|
1853
|
-
import { createEnvironmentRelease, createVerifierSetRelease, verifyEnvironmentRelease as verifyEnvironmentRelease2, verifyVerifierSetRelease as verifyVerifierSetRelease2 } from "@openpond/evals";
|
|
1854
|
-
import { LearningTextAssetSchema, TaskDefinitionSchema, assertLearningContentHash, learningRef as learningRef2, sameLearningRef, sealLearningContent as sealLearningContent3, verifyLearningTextAsset as verifyLearningTextAsset3 } from "@openpond/evals/learning";
|
|
1855
|
-
import { RewardBindingSchema, RewardReleaseSchema, compileBoundGraders } from "@openpond/evals/rewards";
|
|
1856
|
-
import { TasksetReleaseSchema, assertTasksetRelease } from "@openpond/evals/tasksets";
|
|
1857
|
-
import { validateTaskValue } from "@openpond/evals/task-schema";
|
|
1858
|
-
|
|
1859
|
-
// src/model-projects.ts
|
|
1860
|
-
import { z as z11 } from "zod";
|
|
1861
|
-
import { assertBoundedTaskJson } from "@openpond/evals/task-schema";
|
|
1862
|
-
|
|
1863
|
-
// src/protocol.ts
|
|
1864
|
-
var OpenPondProtocolError = class extends Error {
|
|
1865
|
-
code;
|
|
1866
|
-
constructor(code, message) {
|
|
1867
|
-
super(message);
|
|
1868
|
-
this.name = "OpenPondProtocolError";
|
|
1869
|
-
this.code = code;
|
|
1870
|
-
}
|
|
1871
|
-
};
|
|
1872
|
-
function canonicalJson2(value) {
|
|
1873
|
-
return JSON.stringify(normalizeCanonicalJson(value));
|
|
1874
|
-
}
|
|
1875
|
-
function normalizeCanonicalJson(value) {
|
|
1876
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1877
|
-
return value;
|
|
1878
|
-
}
|
|
1879
|
-
if (typeof value === "number") {
|
|
1880
|
-
if (!Number.isFinite(value)) {
|
|
1881
|
-
throw new OpenPondProtocolError(
|
|
1882
|
-
"non_json_value",
|
|
1883
|
-
"Canonical JSON cannot contain a non-finite number."
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
return Object.is(value, -0) ? 0 : value;
|
|
1887
|
-
}
|
|
1888
|
-
if (Array.isArray(value)) {
|
|
1889
|
-
return value.map((entry) => normalizeCanonicalJson(entry));
|
|
1890
|
-
}
|
|
1891
|
-
if (typeof value === "object") {
|
|
1892
|
-
const prototype = Object.getPrototypeOf(value);
|
|
1893
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
1894
|
-
throw new OpenPondProtocolError(
|
|
1895
|
-
"non_json_value",
|
|
1896
|
-
"Canonical JSON accepts only plain objects."
|
|
1897
|
-
);
|
|
1898
|
-
}
|
|
1899
|
-
const result = {};
|
|
1900
|
-
for (const key of Object.keys(value).sort()) {
|
|
1901
|
-
const entry = value[key];
|
|
1902
|
-
if (entry === void 0 || typeof entry === "function" || typeof entry === "symbol") {
|
|
1903
|
-
throw new OpenPondProtocolError(
|
|
1904
|
-
"non_json_value",
|
|
1905
|
-
`Canonical JSON cannot contain ${typeof entry} at ${key}.`
|
|
1906
|
-
);
|
|
1907
|
-
}
|
|
1908
|
-
result[key] = normalizeCanonicalJson(entry);
|
|
1909
|
-
}
|
|
1910
|
-
return result;
|
|
1911
|
-
}
|
|
1912
|
-
throw new OpenPondProtocolError(
|
|
1913
|
-
"non_json_value",
|
|
1914
|
-
`Canonical JSON cannot contain ${typeof value}.`
|
|
1915
|
-
);
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
// src/model-projects.ts
|
|
1919
|
-
var IdSchema = z11.string().trim().min(1).max(500);
|
|
1920
|
-
var HashSchema = z11.string().regex(/^[a-f0-9]{64}$/);
|
|
1921
|
-
var TimestampSchema = z11.string().datetime({ offset: true });
|
|
1922
|
-
var ModelProjectImmutableRefSchema = z11.object({
|
|
1923
|
-
id: IdSchema,
|
|
1924
|
-
contentHash: HashSchema
|
|
1925
|
-
}).strict();
|
|
1926
|
-
var ModelProjectVersionedRefSchema = ModelProjectImmutableRefSchema.extend({
|
|
1927
|
-
revision: z11.number().int().positive()
|
|
1928
|
-
}).strict();
|
|
1929
|
-
var ModelProjectBaseModelSchema = z11.object({
|
|
1930
|
-
schemaVersion: z11.literal("openpond.baseModelPreference.v1"),
|
|
1931
|
-
modelId: IdSchema,
|
|
1932
|
-
revision: z11.string().trim().min(1).max(256).nullable(),
|
|
1933
|
-
tokenizerRevision: z11.string().trim().min(1).max(256).nullable(),
|
|
1934
|
-
chatTemplateHash: z11.string().trim().min(8).max(256).nullable(),
|
|
1935
|
-
modelAssetId: IdSchema.nullable(),
|
|
1936
|
-
source: z11.enum(["managed", "local", "builtin"])
|
|
1937
|
-
}).strict();
|
|
1938
|
-
var ModelProjectTrainingMethodSchema = z11.enum([
|
|
1939
|
-
"sft",
|
|
1940
|
-
"dpo",
|
|
1941
|
-
"grpo",
|
|
1942
|
-
"ppo",
|
|
1943
|
-
"sdft",
|
|
1944
|
-
"opd",
|
|
1945
|
-
"opsd",
|
|
1946
|
-
"sdpo"
|
|
1947
|
-
]);
|
|
1948
|
-
var ModelProjectRecipeDocumentSchema = z11.object({
|
|
1949
|
-
schemaVersion: z11.string().regex(/^openpond\.[A-Za-z0-9]+Recipe\.v\d+$/),
|
|
1950
|
-
method: ModelProjectTrainingMethodSchema,
|
|
1951
|
-
parameterization: z11.enum(["lora", "full"])
|
|
1952
|
-
}).catchall(z11.unknown());
|
|
1953
|
-
var ModelProjectTrainingSetupSchema = z11.object({
|
|
1954
|
-
tasksetRef: ModelProjectVersionedRefSchema.nullable().default(null),
|
|
1955
|
-
rewardBindingRef: ModelProjectVersionedRefSchema.nullable().optional(),
|
|
1956
|
-
tasksetRelease: ModelProjectImmutableRefSchema.nullable().default(null),
|
|
1957
|
-
harnessRelease: ModelProjectImmutableRefSchema.nullable().default(null),
|
|
1958
|
-
baseModel: ModelProjectBaseModelSchema.nullable().default(null),
|
|
1959
|
-
method: ModelProjectTrainingMethodSchema.nullable().default(null),
|
|
1960
|
-
destinationId: IdSchema.nullable().default(null),
|
|
1961
|
-
managedRolloutPlacement: z11.enum(["local", "remote"]).default("remote"),
|
|
1962
|
-
managedGpuPlacementObjective: z11.enum(["fast", "balanced", "economical"]).default("balanced"),
|
|
1963
|
-
managedGpuRequirement: z11.enum(["any", "h100_hbm3"]).default("any"),
|
|
1964
|
-
runPreset: z11.enum(["small", "standard", "custom", "small_experiment"]).nullable().default(null),
|
|
1965
|
-
recipe: ModelProjectRecipeDocumentSchema.nullable().default(null),
|
|
1966
|
-
preferredMaximumSpendUsd: z11.number().nonnegative().nullable().default(null),
|
|
1967
|
-
preferredRetentionDays: z11.number().int().nonnegative().nullable().default(null)
|
|
1968
|
-
}).strict();
|
|
1969
|
-
var HostedModelProjectTrainingSetupSchema = ModelProjectTrainingSetupSchema.omit({ managedGpuRequirement: true });
|
|
1970
|
-
var HostedModelProjectLinkSchema = z11.object({
|
|
1971
|
-
schemaVersion: z11.literal("openpond.hostedModelProjectLink.v1"),
|
|
1972
|
-
apiOrigin: z11.string().url().refine((value) => new URL(value).origin === value, "Use a canonical API origin.").nullable().default(null),
|
|
1973
|
-
teamId: IdSchema,
|
|
1974
|
-
projectId: IdSchema,
|
|
1975
|
-
portableProjectId: IdSchema,
|
|
1976
|
-
revision: z11.number().int().positive(),
|
|
1977
|
-
etag: HashSchema,
|
|
1978
|
-
syncedSourceRevision: z11.number().int().positive(),
|
|
1979
|
-
syncedAt: TimestampSchema,
|
|
1980
|
-
tasksets: z11.array(
|
|
1981
|
-
z11.object({
|
|
1982
|
-
localTasksetId: IdSchema,
|
|
1983
|
-
localTasksetHash: HashSchema.nullable().default(null),
|
|
1984
|
-
releaseId: IdSchema,
|
|
1985
|
-
releaseRevision: z11.number().int().positive(),
|
|
1986
|
-
releaseHash: HashSchema,
|
|
1987
|
-
packageHash: HashSchema.nullable().default(null),
|
|
1988
|
-
hostedTasksetId: IdSchema,
|
|
1989
|
-
syncedAt: TimestampSchema
|
|
1990
|
-
}).strict()
|
|
1991
|
-
).max(1e4).default([])
|
|
1992
|
-
}).strict();
|
|
1993
|
-
var ModelProjectTasksetSyncSchema = z11.object({
|
|
1994
|
-
localTasksetId: IdSchema,
|
|
1995
|
-
releaseId: IdSchema,
|
|
1996
|
-
releaseRevision: z11.number().int().positive(),
|
|
1997
|
-
releaseHash: HashSchema,
|
|
1998
|
-
state: z11.enum(["syncing", "synced", "sync_failed"]),
|
|
1999
|
-
hostedTasksetId: IdSchema.nullable().default(null),
|
|
2000
|
-
lastAttemptAt: TimestampSchema,
|
|
2001
|
-
syncedAt: TimestampSchema.nullable().default(null),
|
|
2002
|
-
lastError: z11.string().trim().min(1).max(5e3).nullable().default(null)
|
|
2003
|
-
}).strict();
|
|
2004
|
-
var ModelProjectSchema = z11.object({
|
|
2005
|
-
schemaVersion: z11.literal("openpond.modelProject.v2"),
|
|
2006
|
-
id: IdSchema,
|
|
2007
|
-
profileId: IdSchema,
|
|
2008
|
-
revision: z11.number().int().positive().default(1),
|
|
2009
|
-
name: z11.string().trim().min(1).max(200),
|
|
2010
|
-
objective: z11.string().trim().max(5e3).nullable(),
|
|
2011
|
-
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
2012
|
-
defaultDestinationId: IdSchema.nullable(),
|
|
2013
|
-
trainingSetup: ModelProjectTrainingSetupSchema,
|
|
2014
|
-
hosted: HostedModelProjectLinkSchema.nullable().default(null),
|
|
2015
|
-
tasksetSyncs: z11.array(ModelProjectTasksetSyncSchema).max(1e4).default([]),
|
|
2016
|
-
createdAt: TimestampSchema,
|
|
2017
|
-
updatedAt: TimestampSchema
|
|
2018
|
-
}).strict();
|
|
2019
|
-
var ModelProjectEditableSchema = ModelProjectSchema.pick({
|
|
2020
|
-
id: true,
|
|
2021
|
-
profileId: true,
|
|
2022
|
-
name: true,
|
|
2023
|
-
objective: true,
|
|
2024
|
-
defaultBaseModel: true,
|
|
2025
|
-
defaultDestinationId: true,
|
|
2026
|
-
trainingSetup: true
|
|
2027
|
-
});
|
|
2028
|
-
var ModelProjectSaveRequestSchema = z11.object({
|
|
2029
|
-
schemaVersion: z11.literal("openpond.modelProjectSave.v1"),
|
|
2030
|
-
operationId: IdSchema,
|
|
2031
|
-
expectedRevision: z11.number().int().nonnegative(),
|
|
2032
|
-
project: ModelProjectEditableSchema
|
|
2033
|
-
}).strict();
|
|
2034
|
-
var ModelProjectConfigurationCheckSchema = z11.object({
|
|
2035
|
-
schemaVersion: z11.literal("openpond.modelProjectConfigurationCheck.v1"),
|
|
2036
|
-
configurationHash: HashSchema,
|
|
2037
|
-
projectId: IdSchema,
|
|
2038
|
-
expectedRevision: z11.number().int().nonnegative(),
|
|
2039
|
-
checkedAt: TimestampSchema,
|
|
2040
|
-
canSave: z11.boolean(),
|
|
2041
|
-
deferred: z11.array(z11.enum(["base_model", "taskset"])).max(2),
|
|
2042
|
-
findings: z11.array(z11.object({
|
|
2043
|
-
code: IdSchema,
|
|
2044
|
-
severity: z11.enum(["error", "warning"]),
|
|
2045
|
-
message: z11.string().min(1).max(5e3),
|
|
2046
|
-
field: z11.string().min(1).max(500).nullable()
|
|
2047
|
-
}).strict()).max(100)
|
|
2048
|
-
}).strict();
|
|
2049
|
-
var ModelProjectBaseModelCandidateSchema = z11.object({
|
|
2050
|
-
id: IdSchema,
|
|
2051
|
-
name: z11.string().min(1).max(500),
|
|
2052
|
-
available: z11.boolean(),
|
|
2053
|
-
preference: ModelProjectBaseModelSchema
|
|
2054
|
-
}).strict();
|
|
2055
|
-
var HostedModelProjectSyncSchema = z11.object({
|
|
2056
|
-
schemaVersion: z11.literal("openpond.hostedModelProjectSync.v2"),
|
|
2057
|
-
portableProjectId: IdSchema,
|
|
2058
|
-
name: z11.string().trim().min(1).max(200),
|
|
2059
|
-
objective: z11.string().trim().max(5e3).nullable(),
|
|
2060
|
-
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
2061
|
-
defaultDestinationId: IdSchema.nullable(),
|
|
2062
|
-
trainingSetup: HostedModelProjectTrainingSetupSchema,
|
|
2063
|
-
sourceRevision: z11.number().int().positive(),
|
|
2064
|
-
sourceUpdatedAt: TimestampSchema,
|
|
2065
|
-
expectedEtag: HashSchema.nullable().default(null)
|
|
2066
|
-
}).strict();
|
|
2067
|
-
var HostedModelProjectSummarySchema = z11.object({
|
|
2068
|
-
id: IdSchema,
|
|
2069
|
-
teamId: IdSchema,
|
|
2070
|
-
portableProjectId: IdSchema,
|
|
2071
|
-
name: z11.string().trim().min(1).max(200),
|
|
2072
|
-
objective: z11.string().trim().max(5e3).nullable(),
|
|
2073
|
-
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
2074
|
-
defaultDestinationId: IdSchema.nullable(),
|
|
2075
|
-
trainingSetup: HostedModelProjectTrainingSetupSchema,
|
|
2076
|
-
sourceRevision: z11.number().int().positive(),
|
|
2077
|
-
sourceUpdatedAt: TimestampSchema,
|
|
2078
|
-
revision: z11.number().int().positive(),
|
|
2079
|
-
etag: HashSchema,
|
|
2080
|
-
createdAt: TimestampSchema,
|
|
2081
|
-
updatedAt: TimestampSchema
|
|
2082
|
-
}).strict();
|
|
2083
|
-
var ModelProjectResourceSummarySchema = z11.object({
|
|
2084
|
-
kind: z11.enum([
|
|
2085
|
-
"taskset_release",
|
|
2086
|
-
"harness_release",
|
|
2087
|
-
"dataset_release",
|
|
2088
|
-
"evidence_set",
|
|
2089
|
-
"model_version",
|
|
2090
|
-
"reward_model_version",
|
|
2091
|
-
"evaluation_receipt"
|
|
2092
|
-
]),
|
|
2093
|
-
ref: ModelProjectImmutableRefSchema,
|
|
2094
|
-
role: z11.string().trim().min(1).max(200).nullable().default(null),
|
|
2095
|
-
updatedAt: TimestampSchema
|
|
2096
|
-
}).strict();
|
|
2097
|
-
var HostedModelProjectDetailSchema = z11.object({
|
|
2098
|
-
project: HostedModelProjectSummarySchema,
|
|
2099
|
-
resources: z11.array(ModelProjectResourceSummarySchema).max(1e4),
|
|
2100
|
-
jobCount: z11.number().int().nonnegative(),
|
|
2101
|
-
latestJobIds: z11.array(IdSchema).max(100)
|
|
2102
|
-
}).strict();
|
|
2103
|
-
var ModelProjectApiErrorSchema = z11.object({
|
|
2104
|
-
schemaVersion: z11.literal("openpond.modelProjectApiError.v2"),
|
|
2105
|
-
code: z11.string().trim().min(1).max(200),
|
|
2106
|
-
message: z11.string().trim().min(1).max(5e3),
|
|
2107
|
-
retryable: z11.boolean().default(false),
|
|
2108
|
-
requestId: z11.string().trim().min(1).max(500).nullable().default(null),
|
|
2109
|
-
details: z11.record(z11.string(), z11.unknown()).default({})
|
|
2110
|
-
}).strict();
|
|
2111
|
-
|
|
2112
|
-
// src/model-starter-execution.ts
|
|
2113
|
-
import { z as z12 } from "zod";
|
|
2114
|
-
import { EnvironmentReleaseSchema, VerifierSetReleaseSchema } from "@openpond/evals";
|
|
2115
|
-
import { JavaScriptEnvironmentDefinitionSchema, assertJavaScriptEnvironmentDefinition } from "@openpond/evals/javascript-environment";
|
|
2116
|
-
import { createLearningTextAsset, learningRef, sealLearningContent, verifyLearningTextAsset } from "@openpond/evals/learning";
|
|
2117
|
-
import { assertBoundedTaskJson as assertBoundedTaskJson2 } from "@openpond/evals/task-schema";
|
|
2118
|
-
var HashSchema2 = z12.string().regex(/^[a-f0-9]{64}$/);
|
|
2119
|
-
var ModelStarterEnvironmentAttemptSchema = z12.object({
|
|
2120
|
-
schemaVersion: z12.literal("openpond.javascriptEnvironmentAttempt.v1"),
|
|
2121
|
-
taskId: z12.string(),
|
|
2122
|
-
status: z12.enum(["completed", "budget_exhausted", "cancelled", "timed_out", "policy_failure", "environment_failure"]),
|
|
2123
|
-
output: z12.string().nullable(),
|
|
2124
|
-
collected: z12.boolean(),
|
|
2125
|
-
environmentCleanupComplete: z12.boolean(),
|
|
2126
|
-
snapshot: z12.object({ definition: ModelProjectVersionedRefSchema, inputHash: HashSchema2, seed: z12.number().int(), initialStateHash: HashSchema2, finalStateHash: HashSchema2, state: z12.record(z12.string(), z12.unknown()), events: z12.array(z12.record(z12.string(), z12.unknown())) }).strict().nullable(),
|
|
2127
|
-
messages: z12.array(z12.unknown()),
|
|
2128
|
-
error: z12.string().nullable(),
|
|
2129
|
-
contentHash: HashSchema2
|
|
2130
|
-
}).strict();
|
|
2131
|
-
var ModelStarterExecutionSchema = z12.object({
|
|
2132
|
-
environment: EnvironmentReleaseSchema,
|
|
2133
|
-
verifierSet: VerifierSetReleaseSchema,
|
|
2134
|
-
javascript: JavaScriptEnvironmentDefinitionSchema
|
|
2135
|
-
}).strict();
|
|
2136
|
-
var ModelStarterToolFixtureScriptSchema = z12.object({
|
|
2137
|
-
actions: z12.array(z12.object({ name: z12.string().min(1).max(64), arguments: z12.record(z12.string(), z12.unknown()) }).strict()).max(1e3)
|
|
2138
|
-
}).strict();
|
|
2139
|
-
function modelStarterExecutionAssetId(context) {
|
|
2140
|
-
if (!context.environmentRelease || !context.verifierSetRelease) throw new Error("Starter execution release references are missing.");
|
|
2141
|
-
return `starter-execution-${sealLearningContent({ environment: context.environmentRelease, verifiers: context.verifierSetRelease }).contentHash}`;
|
|
2142
|
-
}
|
|
2143
|
-
function createModelStarterExecutionAsset(value) {
|
|
2144
|
-
const execution = ModelStarterExecutionSchema.parse(value);
|
|
2145
|
-
assertExecutionIntegrity(execution);
|
|
2146
|
-
const id = modelStarterExecutionAssetId({ environmentRelease: { id: execution.environment.id, contentHash: execution.environment.contentHash }, verifierSetRelease: { id: execution.verifierSet.id, contentHash: execution.verifierSet.contentHash } });
|
|
2147
|
-
const generated = createLearningTextAsset({ text: canonicalJson2(execution), path: "environment/execution.json", mediaType: "application/json", visibility: "host_private" });
|
|
2148
|
-
const { contentHash: _hash, ...content } = generated;
|
|
2149
|
-
return sealLearningContent({ ...content, id, asset: { ...content.asset, id } });
|
|
2150
|
-
}
|
|
2151
|
-
function equal(left, right) {
|
|
2152
|
-
return sealLearningContent({ value: left }).contentHash === sealLearningContent({ value: right }).contentHash;
|
|
2153
|
-
}
|
|
2154
|
-
function assertExecutionIntegrity(execution) {
|
|
2155
|
-
assertJavaScriptEnvironmentDefinition(execution.javascript);
|
|
2156
|
-
for (const resource of [execution.environment, execution.verifierSet]) {
|
|
2157
|
-
const { contentHash: contentHash2, ...content } = resource;
|
|
2158
|
-
if (sealLearningContent(content).contentHash !== contentHash2) throw new Error(`Starter execution resource integrity failed: ${resource.id}.`);
|
|
2159
|
-
}
|
|
2160
|
-
if (!equal(execution.environment.metadata.javascriptEnvironment, learningRef(execution.javascript))) throw new Error("Starter execution resources differ from its declared task context.");
|
|
2161
|
-
}
|
|
2162
|
-
function validateModelStarterExecution(execution, taskset, assets) {
|
|
2163
|
-
if (!execution) {
|
|
2164
|
-
if (taskset.environment.entrypoint === "openpond.javascript-environment.v1") throw new Error("Starter JavaScript execution resources are missing.");
|
|
2165
|
-
return;
|
|
2166
|
-
}
|
|
2167
|
-
const { environment, verifierSet, javascript } = execution;
|
|
2168
|
-
assertExecutionIntegrity(execution);
|
|
2169
|
-
if (!equal(taskset.environmentRelease, { id: environment.id, contentHash: environment.contentHash }) || !equal(taskset.verifierSetRelease, { id: verifierSet.id, contentHash: verifierSet.contentHash }) || !equal(environment.contract, taskset.environment) || !equal(verifierSet.graders, taskset.graders) || !equal(taskset.tools, javascript.tools) || !equal(environment.metadata.javascriptEnvironment, learningRef(javascript))) {
|
|
2170
|
-
throw new Error("Starter execution resources differ from its declared task context.");
|
|
2171
|
-
}
|
|
2172
|
-
const contract = environment.contract;
|
|
2173
|
-
if (contract.entrypoint !== "openpond.javascript-environment.v1" || contract.kind !== "agent" || !contract.stateful || !contract.deterministicSeeds || contract.networkPolicy !== "none" || new Set(contract.lifecycle).size !== 5 || taskset.capabilities.length || taskset.policy.connectedAppScopes.length) {
|
|
2174
|
-
throw new Error("Starter JavaScript environment declares unsupported host capabilities.");
|
|
2175
|
-
}
|
|
2176
|
-
for (const reference of [javascript.module, environment.actionSchemaRef, environment.observationSchemaRef, environment.stateSchemaRef]) {
|
|
2177
|
-
if (!reference) continue;
|
|
2178
|
-
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2179
|
-
if (!asset) throw new Error(`Starter environment asset is missing: ${reference.id}.`);
|
|
2180
|
-
verifyLearningTextAsset(asset, reference);
|
|
2181
|
-
}
|
|
2182
|
-
for (const task of taskset.tasks) {
|
|
2183
|
-
const asset = assets.find((asset2) => asset2.id === task.privilegedContextRef);
|
|
2184
|
-
if (!asset || asset.asset.visibility !== "host_private" || asset.asset.mediaType !== "application/json") {
|
|
2185
|
-
throw new Error(`Starter private initial state is missing: ${task.id}.`);
|
|
2186
|
-
}
|
|
2187
|
-
const state = JSON.parse(verifyLearningTextAsset(asset, asset.asset));
|
|
2188
|
-
if (!state || typeof state !== "object" || Array.isArray(state)) throw new Error(`Starter initial state must be a JSON object: ${task.id}.`);
|
|
2189
|
-
assertBoundedTaskJson2(state, javascript.maxStateBytes);
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
// src/model-taskset-resources.ts
|
|
2194
|
-
import { z as z13 } from "zod";
|
|
2195
|
-
import { EnvironmentReleaseSchema as EnvironmentReleaseSchema2, VerifierSetReleaseSchema as VerifierSetReleaseSchema2, verifyEnvironmentRelease, verifyVerifierSetRelease } from "@openpond/evals";
|
|
2196
|
-
import { createLearningTextAsset as createLearningTextAsset2, sealLearningContent as sealLearningContent2, verifyLearningTextAsset as verifyLearningTextAsset2 } from "@openpond/evals/learning";
|
|
2197
|
-
var ModelTasksetExecutionResourcesSchema = z13.object({ environment: EnvironmentReleaseSchema2, verifierSet: VerifierSetReleaseSchema2 }).strict();
|
|
2198
|
-
|
|
2199
|
-
// src/model-taskset-derivation.ts
|
|
2200
|
-
var OwnerSchema = z14.object({ scopeId: z14.string().trim().min(1).max(500), modelId: z14.string().trim().min(1).max(500) }).strict();
|
|
2201
|
-
var ModelTasksetDerivationSchema = z14.object({
|
|
2202
|
-
schemaVersion: z14.literal("openpond.modelTasksetDerivation.v1"),
|
|
2203
|
-
owner: OwnerSchema,
|
|
2204
|
-
root: ModelProjectVersionedRefSchema,
|
|
2205
|
-
parent: ModelProjectVersionedRefSchema
|
|
2206
|
-
}).strict();
|
|
2207
|
-
var ModelTasksetPackageSchema = z14.object({
|
|
2208
|
-
taskset: TasksetReleaseSchema,
|
|
2209
|
-
taskDefinition: TaskDefinitionSchema,
|
|
2210
|
-
rewardBinding: RewardBindingSchema,
|
|
2211
|
-
rewards: z14.array(RewardReleaseSchema).min(1).max(100),
|
|
2212
|
-
assets: z14.array(LearningTextAssetSchema).max(1e3),
|
|
2213
|
-
executionResources: ModelTasksetExecutionResourcesSchema.optional(),
|
|
2214
|
-
execution: ModelStarterExecutionSchema.optional()
|
|
2215
|
-
}).strict();
|
|
2216
|
-
var same = (left, right) => sealLearningContent3({ value: left }).contentHash === sealLearningContent3({ value: right }).contentHash;
|
|
2217
|
-
function validateModelTasksetPackage(value) {
|
|
2218
|
-
const result = ModelTasksetPackageSchema.parse(value);
|
|
2219
|
-
const { taskset, taskDefinition, rewardBinding, rewards, assets, execution } = result;
|
|
2220
|
-
for (const resource of [taskset, taskDefinition, rewardBinding, ...rewards, ...assets]) assertLearningContentHash(resource);
|
|
2221
|
-
assertTasksetRelease(taskset);
|
|
2222
|
-
if (rewardBinding.recipeRef) throw new Error("Resolve the Reward recipe into one standalone binding before deriving a Taskset.");
|
|
2223
|
-
if (!sameLearningRef(taskDefinition.rewardBinding, learningRef2(rewardBinding))) throw new Error("Taskset definition differs from its Reward binding.");
|
|
2224
|
-
const { policy, environment, environmentRelease, tools, capabilities, verifierSetRelease } = taskset;
|
|
2225
|
-
if (!same(taskDefinition.execution, { policy, environment, ...environmentRelease ? { environmentRelease } : {}, tools, capabilities, ...verifierSetRelease ? { verifierSetRelease } : {} })) throw new Error("Taskset definition differs from its execution resources.");
|
|
2226
|
-
if (!same(taskset.graders, compileBoundGraders(rewardBinding, rewards))) throw new Error("Taskset graders differ from its Reward binding.");
|
|
2227
|
-
if (taskset.metadata.starter !== void 0) {
|
|
2228
|
-
const metadata = z14.object({ taskDefinition: ModelProjectVersionedRefSchema, rewardBinding: ModelProjectVersionedRefSchema }).passthrough().parse(taskset.metadata.starter);
|
|
2229
|
-
if (!sameLearningRef(metadata.taskDefinition, learningRef2(taskDefinition)) || !sameLearningRef(metadata.rewardBinding, learningRef2(rewardBinding))) throw new Error("Taskset metadata differs from its immutable grading resources.");
|
|
2230
|
-
}
|
|
2231
|
-
if (taskset.metadata.rewardExecution !== void 0 && !same(taskset.metadata.rewardExecution, { binding: rewardBinding, rewards })) throw new Error("Taskset embedded Rewards differ from its immutable grading resources.");
|
|
2232
|
-
if (taskset.metadata.rewardBinding !== void 0 && !sameLearningRef(ModelProjectVersionedRefSchema.parse(taskset.metadata.rewardBinding), learningRef2(rewardBinding))) throw new Error("Taskset Reward reference differs from its immutable grading resources.");
|
|
2233
|
-
const resources = result.executionResources ?? execution;
|
|
2234
|
-
if (taskset.environmentRelease && !resources) throw new Error("Deriving a Taskset requires its pinned execution resources.");
|
|
2235
|
-
if (resources && (!verifyEnvironmentRelease2(resources.environment) || !verifyVerifierSetRelease2(resources.verifierSet) || !same(taskset.environmentRelease, { id: resources.environment.id, contentHash: resources.environment.contentHash }) || !same(taskset.verifierSetRelease, { id: resources.verifierSet.id, contentHash: resources.verifierSet.contentHash }) || !same(taskset.environment, resources.environment.contract) || !same(taskset.graders, resources.verifierSet.graders))) throw new Error("Taskset differs from its pinned execution resources.");
|
|
2236
|
-
validateModelStarterExecution(execution, taskset, assets);
|
|
2237
|
-
if (new Set(assets.map((asset) => asset.id)).size !== assets.length) throw new Error("Taskset asset identities must be unique.");
|
|
2238
|
-
for (const asset of assets) verifyLearningTextAsset3(asset, asset.asset);
|
|
2239
|
-
for (const reference of resources ? [resources.environment.actionSchemaRef, resources.environment.observationSchemaRef, resources.environment.stateSchemaRef] : []) {
|
|
2240
|
-
if (!reference) continue;
|
|
2241
|
-
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2242
|
-
if (!asset) throw new Error(`Taskset environment asset is missing: ${reference.id}.`);
|
|
2243
|
-
verifyLearningTextAsset3(asset, reference);
|
|
2244
|
-
}
|
|
2245
|
-
for (const task of taskset.tasks) {
|
|
2246
|
-
if (task.policyVisibleContext.instructions !== taskDefinition.instructions || !validateTaskValue(taskDefinition.inputSchema, task.input).valid || task.expectedOutput !== null && !validateTaskValue(taskDefinition.outputSchema, task.expectedOutput).valid) throw new Error(`Taskset task differs from its declared format: ${task.id}.`);
|
|
2247
|
-
if (task.privilegedContextRef && !assets.some((asset) => asset.id === task.privilegedContextRef && asset.asset.visibility === "host_private")) throw new Error(`Taskset private context is missing: ${task.id}.`);
|
|
2248
|
-
}
|
|
2249
|
-
for (const reward of rewards) {
|
|
2250
|
-
const implementation = reward.implementation;
|
|
2251
|
-
const references = [...reward.assets, ..."verifierRef" in implementation ? [implementation.verifierRef] : [], ..."rubricRef" in implementation ? [implementation.rubricRef] : [], ..."inputContract" in implementation ? [implementation.inputContract] : []];
|
|
2252
|
-
for (const reference of references) {
|
|
2253
|
-
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2254
|
-
if (!asset || reference.visibility === "policy") throw new Error(`Taskset Reward requires its private asset: ${reference.id}.`);
|
|
2255
|
-
verifyLearningTextAsset3(asset, reference);
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
|
-
return result;
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
// src/taskset-package-contracts.ts
|
|
2262
|
-
import { taskBatchPackageMetadata as taskBatchPackageMetadata2 } from "@openpond/evals/learning";
|
|
2263
|
-
|
|
2264
|
-
// src/taskset-package-learning.ts
|
|
2265
|
-
import { z as z16 } from "zod";
|
|
2266
1
|
import {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
kind: z15.literal("reward_model_train"),
|
|
2338
|
-
baseModel: ModelProjectBaseModelSchema,
|
|
2339
|
-
preferenceDatasetRelease: ModelProjectImmutableRefSchema,
|
|
2340
|
-
processorRelease: ModelProjectImmutableRefSchema,
|
|
2341
|
-
recipe: z15.object({
|
|
2342
|
-
schemaVersion: z15.literal("openpond.rewardModelRecipe.v1"),
|
|
2343
|
-
method: z15.literal("reward_model"),
|
|
2344
|
-
parameterization: z15.literal("lora_with_scalar_head")
|
|
2345
|
-
}).catchall(z15.unknown())
|
|
2346
|
-
}).strict();
|
|
2347
|
-
var DeterministicRewardSourceSchema = z15.object({
|
|
2348
|
-
kind: z15.literal("deterministic"),
|
|
2349
|
-
grader: ModelProjectImmutableRefSchema,
|
|
2350
|
-
composer: ModelProjectImmutableRefSchema.nullable().default(null)
|
|
2351
|
-
}).strict();
|
|
2352
|
-
var LearnedRewardSourceSchema = z15.object({
|
|
2353
|
-
kind: z15.literal("learned_reward"),
|
|
2354
|
-
rewardModelVersion: ModelProjectImmutableRefSchema,
|
|
2355
|
-
qualificationReport: ModelProjectImmutableRefSchema.nullable().default(null),
|
|
2356
|
-
evaluationReferences: z15.array(ModelProjectImmutableRefSchema).max(1e3).default([]),
|
|
2357
|
-
scorerArtifact: z15.object({
|
|
2358
|
-
artifactRef: z15.string().trim().min(1).max(2e3),
|
|
2359
|
-
contentHash: HashSchema3,
|
|
2360
|
-
executionReceipt: ModelProjectImmutableRefSchema
|
|
2361
|
-
}).strict(),
|
|
2362
|
-
processorRelease: ModelProjectImmutableRefSchema,
|
|
2363
|
-
rewardComposerRelease: ModelProjectImmutableRefSchema
|
|
2364
|
-
}).strict();
|
|
2365
|
-
var PolicyOptimizationRequestSchema = z15.object({
|
|
2366
|
-
kind: z15.literal("policy_optimize"),
|
|
2367
|
-
baseModel: ModelProjectBaseModelSchema,
|
|
2368
|
-
recipe: ModelProjectRecipeDocumentSchema,
|
|
2369
|
-
rewardSource: z15.discriminatedUnion("kind", [
|
|
2370
|
-
DeterministicRewardSourceSchema,
|
|
2371
|
-
LearnedRewardSourceSchema
|
|
2372
|
-
]),
|
|
2373
|
-
resumeFrom: ModelProjectImmutableRefSchema.nullable().default(null)
|
|
2374
|
-
}).strict();
|
|
2375
|
-
var TrainingJobRequestSchema = z15.discriminatedUnion("kind", [
|
|
2376
|
-
RewardModelTrainingRequestSchema,
|
|
2377
|
-
PolicyOptimizationRequestSchema
|
|
2378
|
-
]);
|
|
2379
|
-
var TrainingJobApprovalSchema = z15.object({
|
|
2380
|
-
approvalHash: HashSchema3,
|
|
2381
|
-
approvedAt: TimestampSchema2,
|
|
2382
|
-
exportApproved: z15.boolean(),
|
|
2383
|
-
maximumSpendUsd: z15.number().nonnegative(),
|
|
2384
|
-
retentionDays: z15.number().int().nonnegative().nullable(),
|
|
2385
|
-
region: z15.string().trim().min(1).max(200).nullable().default(null)
|
|
2386
|
-
}).strict();
|
|
2387
|
-
var TrainingJobSubmissionSchema = z15.object({
|
|
2388
|
-
schemaVersion: z15.literal("openpond.trainingJobSubmission.v2"),
|
|
2389
|
-
idempotencyKey: z15.string().trim().min(1).max(500),
|
|
2390
|
-
name: z15.string().trim().min(1).max(200),
|
|
2391
|
-
source: TrainingJobSourceSchema,
|
|
2392
|
-
job: TrainingJobRequestSchema,
|
|
2393
|
-
requestedCapabilities: z15.array(TrainingCapabilityRequirementSchema).max(1e3),
|
|
2394
|
-
placementObjective: z15.enum(["fast", "balanced", "economical"]),
|
|
2395
|
-
budget: z15.object({
|
|
2396
|
-
maximumSpendUsd: z15.number().nonnegative(),
|
|
2397
|
-
maximumWallSeconds: z15.number().int().positive()
|
|
2398
|
-
}).strict(),
|
|
2399
|
-
approval: TrainingJobApprovalSchema,
|
|
2400
|
-
contentHash: HashSchema3
|
|
2401
|
-
}).strict().superRefine((submission, context) => {
|
|
2402
|
-
if (submission.approval.maximumSpendUsd !== submission.budget.maximumSpendUsd) {
|
|
2403
|
-
context.addIssue({
|
|
2404
|
-
code: "custom",
|
|
2405
|
-
path: ["approval", "maximumSpendUsd"],
|
|
2406
|
-
message: "Approved spend must equal the immutable Job budget."
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2409
|
-
});
|
|
2410
|
-
var TrainingJobSchema = z15.object({
|
|
2411
|
-
schemaVersion: z15.literal("openpond.trainingJob.v2"),
|
|
2412
|
-
id: IdSchema2,
|
|
2413
|
-
teamId: IdSchema2,
|
|
2414
|
-
kind: TrainingJobKindSchema,
|
|
2415
|
-
modelProjectId: IdSchema2,
|
|
2416
|
-
portableProjectId: IdSchema2,
|
|
2417
|
-
sourceProjectRevision: z15.number().int().positive(),
|
|
2418
|
-
submissionHash: HashSchema3,
|
|
2419
|
-
state: TrainingJobStateSchema,
|
|
2420
|
-
phase: z15.string().trim().min(1).max(200),
|
|
2421
|
-
version: z15.number().int().nonnegative(),
|
|
2422
|
-
progress: z15.number().min(0).max(1),
|
|
2423
|
-
rolloutProgress: z15.object({
|
|
2424
|
-
groupsCompleted: z15.number().int().nonnegative(),
|
|
2425
|
-
groupsTarget: z15.number().int().nonnegative(),
|
|
2426
|
-
optimizerUpdatesApplied: z15.number().int().nonnegative(),
|
|
2427
|
-
optimizerUpdatesSkipped: z15.number().int().nonnegative()
|
|
2428
|
-
}).strict(),
|
|
2429
|
-
accruedSpendUsd: z15.number().nonnegative(),
|
|
2430
|
-
terminalReason: z15.string().trim().min(1).max(5e3).nullable(),
|
|
2431
|
-
createdAt: TimestampSchema2,
|
|
2432
|
-
updatedAt: TimestampSchema2,
|
|
2433
|
-
completedAt: TimestampSchema2.nullable()
|
|
2434
|
-
}).strict();
|
|
2435
|
-
var TrainingJobPageSchema = z15.object({
|
|
2436
|
-
schemaVersion: z15.literal("openpond.trainingJobPage.v2"),
|
|
2437
|
-
jobs: z15.array(TrainingJobSchema).max(1e3),
|
|
2438
|
-
nextCursor: z15.string().trim().min(1).max(2e3).nullable()
|
|
2439
|
-
}).strict();
|
|
2440
|
-
var TrainingJobEventSchema = z15.object({
|
|
2441
|
-
schemaVersion: z15.literal("openpond.trainingJobEvent.v2"),
|
|
2442
|
-
id: IdSchema2,
|
|
2443
|
-
jobId: IdSchema2,
|
|
2444
|
-
sequence: z15.number().int().nonnegative(),
|
|
2445
|
-
type: IdSchema2,
|
|
2446
|
-
phase: z15.string().trim().min(1).max(200),
|
|
2447
|
-
message: z15.string().trim().min(1).max(5e3).nullable(),
|
|
2448
|
-
data: z15.record(z15.string(), z15.unknown()).default({}),
|
|
2449
|
-
createdAt: TimestampSchema2
|
|
2450
|
-
}).strict();
|
|
2451
|
-
var TrainingJobLogSchema = z15.object({
|
|
2452
|
-
schemaVersion: z15.literal("openpond.trainingJobLog.v2"),
|
|
2453
|
-
jobId: IdSchema2,
|
|
2454
|
-
sequence: z15.number().int().nonnegative(),
|
|
2455
|
-
level: z15.enum(["debug", "info", "warning", "error"]),
|
|
2456
|
-
message: z15.string().max(2e4),
|
|
2457
|
-
createdAt: TimestampSchema2
|
|
2458
|
-
}).strict();
|
|
2459
|
-
var TrainingJobControlRequestSchema = z15.object({ expectedVersion: z15.number().int().nonnegative() }).strict();
|
|
2460
|
-
var TrainingJobOutputSchema = z15.object({
|
|
2461
|
-
schemaVersion: z15.literal("openpond.trainingJobOutput.v2"),
|
|
2462
|
-
id: IdSchema2,
|
|
2463
|
-
jobId: IdSchema2,
|
|
2464
|
-
kind: z15.enum([
|
|
2465
|
-
"checkpoint",
|
|
2466
|
-
"adapter",
|
|
2467
|
-
"scorer",
|
|
2468
|
-
"metrics",
|
|
2469
|
-
"evaluation",
|
|
2470
|
-
"trace",
|
|
2471
|
-
"receipt"
|
|
2472
|
-
]),
|
|
2473
|
-
artifactRef: z15.string().trim().min(1).max(2e3),
|
|
2474
|
-
contentHash: HashSchema3,
|
|
2475
|
-
sizeBytes: z15.number().int().nonnegative(),
|
|
2476
|
-
metadata: z15.record(z15.string(), z15.unknown()).default({}),
|
|
2477
|
-
createdAt: TimestampSchema2
|
|
2478
|
-
}).strict();
|
|
2479
|
-
var TrainingExecutionReceiptSchema = z15.object({
|
|
2480
|
-
schemaVersion: z15.literal("openpond.trainingExecutionReceipt.v2"),
|
|
2481
|
-
id: IdSchema2,
|
|
2482
|
-
teamId: IdSchema2,
|
|
2483
|
-
jobId: IdSchema2,
|
|
2484
|
-
submissionHash: HashSchema3,
|
|
2485
|
-
manifestHash: HashSchema3,
|
|
2486
|
-
recipeHash: HashSchema3,
|
|
2487
|
-
capabilityHash: HashSchema3,
|
|
2488
|
-
runtimeRelease: ModelProjectImmutableRefSchema,
|
|
2489
|
-
inputs: z15.array(ModelProjectImmutableRefSchema).max(1e4),
|
|
2490
|
-
outputs: z15.array(ModelProjectImmutableRefSchema).max(1e4),
|
|
2491
|
-
spendUsd: z15.number().nonnegative(),
|
|
2492
|
-
durationSeconds: z15.number().nonnegative(),
|
|
2493
|
-
cleanupComplete: z15.boolean(),
|
|
2494
|
-
issuer: IdSchema2,
|
|
2495
|
-
issuedAt: TimestampSchema2,
|
|
2496
|
-
signature: z15.string().trim().min(1).max(1e4).nullable()
|
|
2497
|
-
}).strict();
|
|
2498
|
-
var TrainingJobOutputsSchema = z15.object({
|
|
2499
|
-
schemaVersion: z15.literal("openpond.trainingJobOutputs.v2"),
|
|
2500
|
-
outputs: z15.array(TrainingJobOutputSchema).max(1e4),
|
|
2501
|
-
receipt: TrainingExecutionReceiptSchema.nullable()
|
|
2502
|
-
}).strict();
|
|
2503
|
-
var TrainingApiErrorSchema = z15.object({
|
|
2504
|
-
schemaVersion: z15.literal("openpond.trainingApiError.v2"),
|
|
2505
|
-
code: z15.string().trim().min(1).max(200),
|
|
2506
|
-
message: z15.string().trim().min(1).max(5e3),
|
|
2507
|
-
retryable: z15.boolean().default(false),
|
|
2508
|
-
requestId: z15.string().trim().min(1).max(500).nullable().default(null),
|
|
2509
|
-
details: z15.record(z15.string(), z15.unknown()).default({})
|
|
2510
|
-
}).strict();
|
|
2511
|
-
var TrainingCapabilitiesSchema = z15.object({
|
|
2512
|
-
schemaVersion: z15.literal("openpond.trainingCapabilities.v2"),
|
|
2513
|
-
capabilityHash: HashSchema3,
|
|
2514
|
-
jobKinds: z15.array(TrainingJobKindSchema),
|
|
2515
|
-
methods: z15.array(z15.string().trim().min(1).max(200)),
|
|
2516
|
-
placements: z15.array(
|
|
2517
|
-
z15.enum(["local", "remote", "colocated", "provider_native"])
|
|
2518
|
-
),
|
|
2519
|
-
controls: z15.object({
|
|
2520
|
-
cancel: z15.boolean(),
|
|
2521
|
-
stopAfterGroup: z15.boolean(),
|
|
2522
|
-
resumeFromCheckpoint: z15.boolean()
|
|
2523
|
-
}).strict(),
|
|
2524
|
-
limits: z15.object({
|
|
2525
|
-
maximumSpendUsd: z15.number().nonnegative(),
|
|
2526
|
-
maximumWallSeconds: z15.number().int().positive(),
|
|
2527
|
-
maximumArtifactBytes: z15.number().int().positive()
|
|
2528
|
-
}).strict(),
|
|
2529
|
-
checkedAt: TimestampSchema2,
|
|
2530
|
-
expiresAt: TimestampSchema2
|
|
2531
|
-
}).strict();
|
|
2532
|
-
|
|
2533
|
-
// src/taskset-package-learning.ts
|
|
2534
|
-
var TasksetPackageLearningResourcesSchema = z16.object({
|
|
2535
|
-
batch: TaskBatchSchema,
|
|
2536
|
-
evidence: z16.array(TaskEvidenceSchema).min(1).max(1e4),
|
|
2537
|
-
decisions: z16.array(TaskAdmissionDecisionSchema).min(1).max(1e4),
|
|
2538
|
-
sources: z16.array(LearningSourceSchema).min(1).max(1e4),
|
|
2539
|
-
assets: z16.array(LearningTextAssetSchema2).max(1e3)
|
|
2540
|
-
}).strict();
|
|
2541
|
-
function learningPackageContextFiles(resources) {
|
|
2542
|
-
return resources.evidence.filter((evidence) => evidence.submission.evaluatorContext !== null).map((evidence) => {
|
|
2543
|
-
const text = canonicalJson2(evidence.submission.evaluatorContext);
|
|
2544
|
-
const bytes = new TextEncoder().encode(text);
|
|
2545
|
-
return {
|
|
2546
|
-
asset: {
|
|
2547
|
-
id: `task-evidence:${evidence.contentHash}`,
|
|
2548
|
-
path: `learning/context/${evidence.contentHash}.json`,
|
|
2549
|
-
contentHash: sha256(bytes),
|
|
2550
|
-
sizeBytes: bytes.byteLength,
|
|
2551
|
-
mediaType: "application/json",
|
|
2552
|
-
visibility: "host_private"
|
|
2553
|
-
},
|
|
2554
|
-
base64: btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(""))
|
|
2555
|
-
};
|
|
2556
|
-
});
|
|
2557
|
-
}
|
|
2558
|
-
function validateTasksetLearningResources(taskset, input) {
|
|
2559
|
-
const resources = TasksetPackageLearningResourcesSchema.parse(input);
|
|
2560
|
-
const metadata = taskBatchPackageMetadata(taskset);
|
|
2561
|
-
if (!sameLearningRef2(learningRef3(resources.batch), metadata.batch)) throw new Error("Taskset learning batch differs from its admission metadata.");
|
|
2562
|
-
for (const collection of [resources.evidence, resources.decisions, resources.sources, resources.assets]) {
|
|
2563
|
-
const identities = /* @__PURE__ */ new Set();
|
|
2564
|
-
for (const resource of collection) {
|
|
2565
|
-
assertLearningContentHash2(resource);
|
|
2566
|
-
const key = `${resource.id}:${resource.revision}`;
|
|
2567
|
-
if (identities.has(key)) throw new Error("Taskset learning resource identities must be unique.");
|
|
2568
|
-
identities.add(key);
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
if (resources.evidence.length !== resources.batch.examples.length || resources.decisions.length !== resources.batch.examples.length) throw new Error("Taskset learning snapshots must match the admitted batch inventory.");
|
|
2572
|
-
for (const evidence of resources.evidence) {
|
|
2573
|
-
const source = resources.sources.find((source2) => sameLearningRef2(learningRef3(source2), evidence.source));
|
|
2574
|
-
if (!source || !sameLearningRef2(source.taskDefinition, learningRef3(metadata.definition))) throw new Error("Taskset evidence source differs from its task definition.");
|
|
2575
|
-
}
|
|
2576
|
-
if (resources.sources.some((source) => !resources.evidence.some((evidence) => sameLearningRef2(evidence.source, learningRef3(source))))) throw new Error("Taskset package includes an unrelated learning source.");
|
|
2577
|
-
const rewardAssets = metadata.rewards.flatMap((reward) => [
|
|
2578
|
-
...reward.assets,
|
|
2579
|
-
...reward.implementation.kind === "custom_verifier" ? [reward.implementation.verifierRef] : reward.implementation.kind === "model_judge" || reward.implementation.kind === "human" ? [reward.implementation.rubricRef] : [],
|
|
2580
|
-
..."inputContract" in reward.implementation ? [reward.implementation.inputContract] : []
|
|
2581
|
-
]);
|
|
2582
|
-
for (const ref of rewardAssets) {
|
|
2583
|
-
const asset = resources.assets.find((asset2) => asset2.id === ref.id);
|
|
2584
|
-
if (!asset) throw new Error("Taskset learning Reward asset is missing.");
|
|
2585
|
-
verifyLearningTextAsset4(asset, ref);
|
|
2586
|
-
}
|
|
2587
|
-
if (resources.assets.some((asset) => !rewardAssets.some((ref) => ref.id === asset.id))) throw new Error("Taskset package includes an unrelated learning asset.");
|
|
2588
|
-
const compiled = compileTaskBatch({
|
|
2589
|
-
batch: resources.batch,
|
|
2590
|
-
definition: metadata.definition,
|
|
2591
|
-
binding: metadata.binding,
|
|
2592
|
-
rewards: metadata.rewards,
|
|
2593
|
-
evidence: resources.evidence,
|
|
2594
|
-
decisions: resources.decisions
|
|
2595
|
-
});
|
|
2596
|
-
const compiledMetadata = taskBatchPackageMetadata(compiled);
|
|
2597
|
-
if (contentHash(compiledMetadata) !== contentHash(metadata)) throw new Error("Taskset admission metadata differs from its reviewed snapshots.");
|
|
2598
|
-
const execution = (release) => ({ policy: release.policy, environment: release.environment, tools: release.tools });
|
|
2599
|
-
if (contentHash(execution(compiled)) !== contentHash(execution(taskset))) throw new Error("Taskset execution differs from its reviewed task definition.");
|
|
2600
|
-
const taskContent = (task) => ({
|
|
2601
|
-
id: task.id,
|
|
2602
|
-
clusterKey: task.clusterKey,
|
|
2603
|
-
split: task.split,
|
|
2604
|
-
input: task.input,
|
|
2605
|
-
expectedOutput: task.expectedOutput,
|
|
2606
|
-
policyVisibleContext: task.policyVisibleContext,
|
|
2607
|
-
privilegedContextRef: task.privilegedContextRef,
|
|
2608
|
-
artifactRefs: task.artifactRefs,
|
|
2609
|
-
requiredOutputs: task.requiredOutputs ?? [],
|
|
2610
|
-
tags: task.tags
|
|
2611
|
-
});
|
|
2612
|
-
if (contentHash(compiled.tasks.map(taskContent)) !== contentHash(taskset.tasks.map(taskContent))) throw new Error("Taskset rows differ from their reviewed evidence.");
|
|
2613
|
-
return resources;
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
// src/model-taskset-authoring-lineage.ts
|
|
2617
|
-
import { sameLearningRef as sameLearningRef3 } from "@openpond/evals/learning";
|
|
2618
|
-
|
|
2619
|
-
// src/model-taskset-authoring-contracts.ts
|
|
2620
|
-
import { z as z17 } from "zod";
|
|
2621
|
-
import { LearningRevisionRefSchema } from "@openpond/evals/learning";
|
|
2622
|
-
var IdSchema3 = LearningRevisionRefSchema.shape.id;
|
|
2623
|
-
var HashSchema4 = z17.string().regex(/^[a-f0-9]{64}$/);
|
|
2624
|
-
var ModelTasksetAuthoringOwnerSchema = z17.object({ scopeId: IdSchema3, modelId: IdSchema3 }).strict();
|
|
2625
|
-
var ModelTasksetAuthoringSchema = z17.object({
|
|
2626
|
-
schemaVersion: z17.literal("openpond.modelTasksetAuthoring.v1"),
|
|
2627
|
-
owner: ModelTasksetAuthoringOwnerSchema,
|
|
2628
|
-
root: LearningRevisionRefSchema,
|
|
2629
|
-
parent: LearningRevisionRefSchema
|
|
2630
|
-
}).strict();
|
|
2631
|
-
var ModelTasksetDraftRequestSchema = z17.object({
|
|
2632
|
-
schemaVersion: z17.literal("openpond.modelTasksetDraftRequest.v1"),
|
|
2633
|
-
operationId: IdSchema3,
|
|
2634
|
-
modelId: IdSchema3,
|
|
2635
|
-
expectedModelRevision: z17.number().int().positive(),
|
|
2636
|
-
sourcePackageHash: HashSchema4
|
|
2637
|
-
}).strict();
|
|
2638
|
-
var ModelTasksetDraftPreparationSchema = z17.object({
|
|
2639
|
-
schemaVersion: z17.literal("openpond.modelTasksetDraftPreparation.v1"),
|
|
2640
|
-
draftId: IdSchema3,
|
|
2641
|
-
requestHash: HashSchema4,
|
|
2642
|
-
sourcePackageHash: HashSchema4,
|
|
2643
|
-
sourceTasksetRef: LearningRevisionRefSchema,
|
|
2644
|
-
tasksetId: IdSchema3,
|
|
2645
|
-
tasksetRevision: z17.number().int().positive(),
|
|
2646
|
-
lineage: ModelTasksetAuthoringSchema
|
|
2647
|
-
}).strict();
|
|
2648
|
-
var TasksetDraftFilePathSchema = z17.string().min(1).max(1024).refine((value) => !value.includes("\\") && !value.includes(":") && !value.includes("\0") && !value.startsWith("/") && !value.split("/").some((part) => !part || part === "." || part === ".." || part.startsWith(".env")), "Use a relative Taskset file path without environment files.");
|
|
2649
|
-
var TasksetDraftFileInfoSchema = z17.object({
|
|
2650
|
-
path: TasksetDraftFilePathSchema,
|
|
2651
|
-
sizeBytes: z17.number().int().nonnegative(),
|
|
2652
|
-
writable: z17.boolean()
|
|
2653
|
-
}).strict();
|
|
2654
|
-
var TasksetDraftFileContentSchema = z17.object({ encoding: z17.enum(["utf8", "base64"]), data: z17.string().max(8e6) }).strict();
|
|
2655
|
-
var TasksetDraftFileSchema = TasksetDraftFileInfoSchema.extend({ contentHash: HashSchema4, content: TasksetDraftFileContentSchema }).strict();
|
|
2656
|
-
var TasksetDraftFileMutationSchema = z17.object({
|
|
2657
|
-
draftId: IdSchema3,
|
|
2658
|
-
expectedDraftRevision: z17.number().int().positive(),
|
|
2659
|
-
path: TasksetDraftFilePathSchema,
|
|
2660
|
-
expectedFileHash: HashSchema4.nullable(),
|
|
2661
|
-
content: TasksetDraftFileContentSchema.nullable()
|
|
2662
|
-
}).strict();
|
|
2663
|
-
|
|
2664
|
-
// src/model-taskset-authoring-lineage.ts
|
|
2665
|
-
function modelAuthoredTasksetId(lineage) {
|
|
2666
|
-
return `model-authored-taskset-${contentHash({ owner: lineage.owner, root: lineage.root })}`;
|
|
2667
|
-
}
|
|
2668
|
-
function assertModelTasksetAuthoring(taskset) {
|
|
2669
|
-
if (taskset.metadata.modelTasksetAuthoring === void 0) return null;
|
|
2670
|
-
const lineage = ModelTasksetAuthoringSchema.parse(taskset.metadata.modelTasksetAuthoring);
|
|
2671
|
-
if (taskset.id !== modelAuthoredTasksetId(lineage) || (taskset.revision === 1 ? !sameLearningRef3(lineage.parent, lineage.root) : lineage.parent.id !== taskset.id || lineage.parent.revision !== taskset.revision - 1)) {
|
|
2672
|
-
throw new Error("Authored Taskset revision differs from its ownership lineage.");
|
|
2673
|
-
}
|
|
2674
|
-
return lineage;
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
// src/taskset-package-execution.ts
|
|
2678
|
-
import { LearningTextAssetSchema as LearningTextAssetSchema3, sealLearningContent as sealLearningContent4 } from "@openpond/evals/learning";
|
|
2679
|
-
|
|
2680
|
-
// src/taskset-package-files.ts
|
|
2681
|
-
import { z as z18 } from "zod";
|
|
2682
|
-
var MAX_TASKSET_PACKAGE_BYTES = 64 * 1024 * 1024;
|
|
2683
|
-
var TasksetPackageFileSchema = z18.object({
|
|
2684
|
-
asset: ImmutableAssetRefSchema,
|
|
2685
|
-
base64: z18.string().max(Math.ceil(MAX_TASKSET_PACKAGE_BYTES / 3) * 4)
|
|
2686
|
-
}).strict();
|
|
2687
|
-
function decodeTasksetPackageFile(value) {
|
|
2688
|
-
const file = TasksetPackageFileSchema.parse(value);
|
|
2689
|
-
const raw = atob(file.base64);
|
|
2690
|
-
if (btoa(raw) !== file.base64) throw new Error(`Taskset asset ${file.asset.id} has noncanonical base64.`);
|
|
2691
|
-
const bytes = Uint8Array.from(raw, (character) => character.charCodeAt(0));
|
|
2692
|
-
if (bytes.byteLength !== file.asset.sizeBytes || sha256(bytes) !== file.asset.contentHash) throw new Error(`Taskset asset ${file.asset.id} differs from its immutable bytes.`);
|
|
2693
|
-
return bytes;
|
|
2694
|
-
}
|
|
2695
|
-
|
|
2696
|
-
// src/taskset-package-execution.ts
|
|
2697
|
-
function resolveTasksetPackageExecution(input) {
|
|
2698
|
-
if (input.taskset.environment.entrypoint !== "openpond.javascript-environment.v1") return null;
|
|
2699
|
-
const byId = new Map(input.files.map((file) => [file.asset.id, file]));
|
|
2700
|
-
const read = (id) => {
|
|
2701
|
-
const file = byId.get(id);
|
|
2702
|
-
if (!file) throw new Error(`Taskset environment asset is missing: ${id}.`);
|
|
2703
|
-
if (file.asset.sizeBytes > 524288) throw new Error("Taskset environment source exceeds the authored asset limit.");
|
|
2704
|
-
const text = new TextDecoder("utf-8", { fatal: true }).decode(decodeTasksetPackageFile(file));
|
|
2705
|
-
return LearningTextAssetSchema3.parse(sealLearningContent4({ schemaVersion: "openpond.learningTextAsset.v1", id, revision: 1, asset: file.asset, text }));
|
|
2706
|
-
};
|
|
2707
|
-
let execution;
|
|
2708
|
-
if (input.modelResources) {
|
|
2709
|
-
if (!input.modelResources.execution) throw new Error("Bound Taskset JavaScript execution resources are missing.");
|
|
2710
|
-
execution = ModelStarterExecutionSchema.parse(input.modelResources.execution);
|
|
2711
|
-
} else {
|
|
2712
|
-
const declaration = read(modelStarterExecutionAssetId(input.taskset));
|
|
2713
|
-
if (declaration.asset.visibility !== "host_private" || declaration.asset.mediaType !== "application/json" || declaration.asset.path !== "environment/execution.json") throw new Error("Taskset execution declaration must be private JSON at environment/execution.json.");
|
|
2714
|
-
execution = ModelStarterExecutionSchema.parse(JSON.parse(declaration.text));
|
|
2715
|
-
}
|
|
2716
|
-
const ids = /* @__PURE__ */ new Set([
|
|
2717
|
-
execution.javascript.module.id,
|
|
2718
|
-
...[execution.environment.actionSchemaRef, execution.environment.observationSchemaRef, execution.environment.stateSchemaRef].flatMap((ref) => ref ? [ref.id] : []),
|
|
2719
|
-
...input.taskset.tasks.flatMap((task) => task.privilegedContextRef ? [task.privilegedContextRef] : [])
|
|
2720
|
-
]);
|
|
2721
|
-
const assets = [...ids].map(read);
|
|
2722
|
-
validateModelStarterExecution(execution, input.taskset, assets);
|
|
2723
|
-
return { execution, assets };
|
|
2724
|
-
}
|
|
2725
|
-
function createTasksetPackageExecutionFile(execution) {
|
|
2726
|
-
const asset = createModelStarterExecutionAsset(execution);
|
|
2727
|
-
const bytes = new TextEncoder().encode(asset.text);
|
|
2728
|
-
let raw = "";
|
|
2729
|
-
for (const byte of bytes) raw += String.fromCharCode(byte);
|
|
2730
|
-
return { asset: asset.asset, base64: btoa(raw) };
|
|
2731
|
-
}
|
|
2732
|
-
|
|
2733
|
-
// src/taskset-package-contracts.ts
|
|
2734
|
-
var BoundModelResourcesSchema = ModelTasksetPackageSchema.omit({ taskset: true, executionResources: true });
|
|
2735
|
-
var TasksetPackageContentSchema = z19.object({
|
|
2736
|
-
schemaVersion: z19.literal("openpond.tasksetPackage.v1"),
|
|
2737
|
-
taskset: TasksetReleaseSchema2,
|
|
2738
|
-
environment: EnvironmentReleaseSchema3,
|
|
2739
|
-
verifierSet: VerifierSetReleaseSchema3,
|
|
2740
|
-
files: z19.array(TasksetPackageFileSchema).max(1e4),
|
|
2741
|
-
modelResources: BoundModelResourcesSchema.optional(),
|
|
2742
|
-
learningResources: TasksetPackageLearningResourcesSchema.optional()
|
|
2743
|
-
}).strict();
|
|
2744
|
-
var TasksetPackageSchema = TasksetPackageContentSchema.extend({ contentHash: z19.string().regex(/^[a-f0-9]{64}$/) }).strict();
|
|
2745
|
-
function tasksetPackageRewardBinding(value) {
|
|
2746
|
-
return value.learningResources ? taskBatchPackageMetadata2(value.taskset).binding : value.modelResources?.rewardBinding ?? null;
|
|
2747
|
-
}
|
|
2748
|
-
function resolveTasksetPackageInstructions(value) {
|
|
2749
|
-
if (value.learningResources) return taskBatchPackageMetadata2(value.taskset).definition.instructions;
|
|
2750
|
-
if (value.modelResources) return value.modelResources.taskDefinition.instructions;
|
|
2751
|
-
const authoring = z19.object({ instructions: z19.string().max(2e4).optional() }).passthrough().parse(value.taskset.metadata.ordinaryAuthoring ?? {});
|
|
2752
|
-
return authoring.instructions ?? "";
|
|
2753
|
-
}
|
|
2754
|
-
function validateTasksetPackage(value) {
|
|
2755
|
-
assertBoundedTaskJson3(value, MAX_TASKSET_PACKAGE_BYTES);
|
|
2756
|
-
const result = TasksetPackageSchema.parse(value);
|
|
2757
|
-
const { contentHash: hash, ...content } = result;
|
|
2758
|
-
if (contentHash(content) !== hash) throw new Error("Taskset package content hash differs from its bytes.");
|
|
2759
|
-
const { taskset, environment, verifierSet } = result;
|
|
2760
|
-
assertTasksetRelease2(taskset);
|
|
2761
|
-
const authoring = assertModelTasksetAuthoring(taskset);
|
|
2762
|
-
if (authoring && (result.modelResources || result.learningResources)) throw new Error("Taskset package cannot declare competing authoring graphs.");
|
|
2763
|
-
if (!verifyEnvironmentRelease3(environment) || !verifyVerifierSetRelease3(verifierSet) || !same2(taskset.environmentRelease, { id: environment.id, contentHash: environment.contentHash }) || !same2(taskset.verifierSetRelease, { id: verifierSet.id, contentHash: verifierSet.contentHash }) || !same2(taskset.environment, environment.contract) || !same2(taskset.graders, verifierSet.graders)) {
|
|
2764
|
-
throw new Error("Taskset package execution releases do not match its Taskset.");
|
|
2765
|
-
}
|
|
2766
|
-
const files = /* @__PURE__ */ new Map();
|
|
2767
|
-
for (const file of result.files) {
|
|
2768
|
-
if (files.has(file.asset.id)) throw new Error(`Duplicate Taskset asset identity: ${file.asset.id}.`);
|
|
2769
|
-
decodeTasksetPackageFile(file);
|
|
2770
|
-
files.set(file.asset.id, file);
|
|
2771
|
-
}
|
|
2772
|
-
function requireAsset(ref) {
|
|
2773
|
-
const file = files.get(ref.id);
|
|
2774
|
-
if (!file || !same2(file.asset, ref)) throw new Error(`Taskset package asset is missing or mismatched: ${ref.id}.`);
|
|
2775
|
-
}
|
|
2776
|
-
for (const task of taskset.tasks) {
|
|
2777
|
-
for (const asset of task.artifactRefs) requireAsset(asset);
|
|
2778
|
-
for (const output of task.requiredOutputs ?? []) if (output.schemaRef) requireAsset(output.schemaRef);
|
|
2779
|
-
if (task.privilegedContextRef && files.get(task.privilegedContextRef)?.asset.visibility !== "host_private") {
|
|
2780
|
-
throw new Error(`Taskset package private context is missing: ${task.id}.`);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
for (const ref of [environment.actionSchemaRef, environment.observationSchemaRef, environment.stateSchemaRef]) if (ref) requireAsset(ref);
|
|
2784
|
-
for (const grader of taskset.graders) {
|
|
2785
|
-
const ref = "verifierRef" in grader ? grader.verifierRef : "rubricRef" in grader ? grader.rubricRef : null;
|
|
2786
|
-
if (ref) {
|
|
2787
|
-
requireAsset(ref);
|
|
2788
|
-
if (ref.visibility === "policy") throw new Error(`Taskset grader asset must be private: ${ref.id}.`);
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
if (taskset.metrics?.customAggregator) {
|
|
2792
|
-
const aggregator = taskset.metrics.customAggregator;
|
|
2793
|
-
const modules = result.files.filter((file) => file.asset.path === aggregator.module);
|
|
2794
|
-
if (modules.length !== 1 || modules[0].asset.contentHash !== aggregator.contentHash || modules[0].asset.sizeBytes > 524288 || modules[0].asset.visibility === "policy") {
|
|
2795
|
-
throw new Error("Taskset metric module is missing or mismatched, public, or exceeds the source limit.");
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
for (const declarations of [taskset.metadata.environmentResources, environment.metadata.resources]) {
|
|
2799
|
-
if (declarations === void 0) continue;
|
|
2800
|
-
for (const resource of z19.array(z19.object({ path: z19.string().min(1) }).passthrough()).parse(declarations)) {
|
|
2801
|
-
if (!result.files.some((file) => file.asset.path === resource.path)) throw new Error(`Taskset environment resource is missing: ${resource.path}.`);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
if (result.learningResources) {
|
|
2805
|
-
if (result.modelResources) throw new Error("Taskset package cannot declare competing authoring graphs.");
|
|
2806
|
-
const learning = validateTasksetLearningResources(taskset, result.learningResources);
|
|
2807
|
-
for (const expected of learningPackageContextFiles(learning)) {
|
|
2808
|
-
if (!same2(files.get(expected.asset.id), expected)) throw new Error("Taskset private context differs from its reviewed evidence.");
|
|
2809
|
-
}
|
|
2810
|
-
for (const asset of learning.assets) requireAsset(asset.asset);
|
|
2811
|
-
} else if (result.modelResources) {
|
|
2812
|
-
const model = validateModelTasksetPackage({ ...result.modelResources, taskset, executionResources: { environment, verifierSet } });
|
|
2813
|
-
for (const asset of model.assets) requireAsset(asset.asset);
|
|
2814
|
-
} else if (["starter", "rewardBinding", "rewardExecution", "modelTasksetDerivation", "learning"].some((key) => taskset.metadata[key] !== void 0)) {
|
|
2815
|
-
throw new Error("Bound Taskset publication requires its complete model resources.");
|
|
2816
|
-
}
|
|
2817
|
-
resolveTasksetPackageExecution(result);
|
|
2818
|
-
resolveTasksetPackageInstructions(result);
|
|
2819
|
-
return result;
|
|
2820
|
-
}
|
|
2821
|
-
function createTasksetPackage(value) {
|
|
2822
|
-
assertBoundedTaskJson3(value, MAX_TASKSET_PACKAGE_BYTES);
|
|
2823
|
-
const content = TasksetPackageContentSchema.parse(value);
|
|
2824
|
-
return validateTasksetPackage({ ...content, contentHash: contentHash(content) });
|
|
2825
|
-
}
|
|
2826
|
-
function same2(left, right) {
|
|
2827
|
-
return contentHash({ value: left }) === contentHash({ value: right });
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
// src/taskset-package-client.ts
|
|
2831
|
-
import { z as z21 } from "zod";
|
|
2832
|
-
|
|
2833
|
-
// src/taskset-catalog.ts
|
|
2834
|
-
import { z as z20 } from "zod";
|
|
2835
|
-
var IdSchema4 = z20.string().trim().min(1).max(500);
|
|
2836
|
-
var HashSchema5 = z20.string().regex(/^[a-f0-9]{64}$/);
|
|
2837
|
-
var TasksetCatalogReleaseRefSchema = z20.object({ id: IdSchema4, revision: z20.number().int().positive(), contentHash: HashSchema5 }).strict();
|
|
2838
|
-
var HostedTasksetSummarySchema = z20.object({
|
|
2839
|
-
schemaVersion: z20.literal("openpond.hostedTasksetSummary.v1"),
|
|
2840
|
-
id: IdSchema4,
|
|
2841
|
-
teamId: IdSchema4,
|
|
2842
|
-
release: TasksetCatalogReleaseRefSchema,
|
|
2843
|
-
name: z20.string().min(1).max(500),
|
|
2844
|
-
description: z20.string().max(2e4),
|
|
2845
|
-
taskCount: z20.number().int().nonnegative(),
|
|
2846
|
-
buildIntent: z20.string().min(1).max(100),
|
|
2847
|
-
methodHint: z20.string().min(1).max(100).nullable(),
|
|
2848
|
-
packageBytes: z20.number().int().nonnegative().nullable(),
|
|
2849
|
-
storedBytes: z20.number().int().nonnegative().nullable(),
|
|
2850
|
-
createdAt: z20.string().datetime({ offset: true })
|
|
2851
|
-
}).strict();
|
|
2852
|
-
var TasksetCatalogQuerySchema = z20.object({
|
|
2853
|
-
afterId: IdSchema4.optional(),
|
|
2854
|
-
limit: z20.number().int().min(1).max(100).default(30),
|
|
2855
|
-
modelProjectId: IdSchema4.optional()
|
|
2856
|
-
}).strict();
|
|
2857
|
-
var TasksetCatalogPageSchema = z20.object({
|
|
2858
|
-
items: z20.array(HostedTasksetSummarySchema).max(100),
|
|
2859
|
-
nextCursor: IdSchema4.nullable()
|
|
2860
|
-
}).strict();
|
|
2861
|
-
var TasksetCatalogErrorSchema = z20.object({
|
|
2862
|
-
code: z20.string().min(1),
|
|
2863
|
-
message: z20.string().min(1)
|
|
2864
|
-
}).strict();
|
|
2865
|
-
|
|
2866
|
-
// src/taskset-package-client.ts
|
|
2867
|
-
import { learningRef as learningRef4 } from "@openpond/evals/learning";
|
|
2868
|
-
var IdSchema5 = z21.string().trim().min(1).max(500);
|
|
2869
|
-
var HashSchema6 = z21.string().regex(/^[a-f0-9]{64}$/);
|
|
2870
|
-
var TasksetPackageModelConfigurationSchema = HostedModelProjectSyncSchema.pick({
|
|
2871
|
-
portableProjectId: true,
|
|
2872
|
-
name: true,
|
|
2873
|
-
objective: true,
|
|
2874
|
-
defaultBaseModel: true,
|
|
2875
|
-
defaultDestinationId: true,
|
|
2876
|
-
sourceRevision: true,
|
|
2877
|
-
sourceUpdatedAt: true
|
|
2878
|
-
}).extend({ trainingSetup: HostedModelProjectTrainingSetupSchema.omit({ tasksetRef: true, rewardBindingRef: true, tasksetRelease: true, recipe: true }) }).strict();
|
|
2879
|
-
var TasksetPackagePublicationSchema = z21.object({
|
|
2880
|
-
schemaVersion: z21.literal("openpond.tasksetPackagePublication.v1"),
|
|
2881
|
-
operationId: IdSchema5,
|
|
2882
|
-
modelProjectId: IdSchema5,
|
|
2883
|
-
expectedProjectEtag: HashSchema6.nullable(),
|
|
2884
|
-
name: z21.string().trim().min(1).max(200),
|
|
2885
|
-
description: z21.string().max(5e3),
|
|
2886
|
-
buildIntent: z21.enum(["demonstrations", "preferences", "verifiable_reward", "rubric", "discovery"]),
|
|
2887
|
-
methodHint: z21.enum(["sft", "dpo", "grpo", "ppo"]).nullable(),
|
|
2888
|
-
package: TasksetPackageSchema,
|
|
2889
|
-
modelConfiguration: TasksetPackageModelConfigurationSchema.optional(),
|
|
2890
|
-
selection: z21.enum(["select", "attach"]).optional()
|
|
2891
|
-
}).strict().refine((value) => value.selection !== "attach" || value.modelConfiguration === void 0, "Attachment-only publication cannot replace Model configuration.");
|
|
2892
|
-
var TasksetPackageReceiptSchema = z21.object({
|
|
2893
|
-
schemaVersion: z21.literal("openpond.tasksetPackageReceipt.v1"),
|
|
2894
|
-
teamId: IdSchema5,
|
|
2895
|
-
modelProjectId: IdSchema5,
|
|
2896
|
-
operationId: IdSchema5,
|
|
2897
|
-
taskset: TasksetCatalogReleaseRefSchema,
|
|
2898
|
-
packageHash: HashSchema6,
|
|
2899
|
-
hostedTasksetId: IdSchema5,
|
|
2900
|
-
projectEtag: HashSchema6,
|
|
2901
|
-
project: HostedModelProjectSummarySchema.optional(),
|
|
2902
|
-
selection: z21.enum(["select", "attach"]).optional()
|
|
2903
|
-
}).strict();
|
|
2904
|
-
var TasksetPackageReadbackSchema = z21.object({
|
|
2905
|
-
schemaVersion: z21.literal("openpond.tasksetPackageReadback.v1"),
|
|
2906
|
-
teamId: IdSchema5,
|
|
2907
|
-
modelProjectId: IdSchema5,
|
|
2908
|
-
package: TasksetPackageSchema
|
|
2909
|
-
}).strict();
|
|
2910
|
-
var OpenPondTasksetPackageError = class extends Error {
|
|
2911
|
-
constructor(status, code, message) {
|
|
2912
|
-
super(message);
|
|
2913
|
-
this.status = status;
|
|
2914
|
-
this.code = code;
|
|
2915
|
-
this.name = "OpenPondTasksetPackageError";
|
|
2916
|
-
}
|
|
2917
|
-
status;
|
|
2918
|
-
code;
|
|
2919
|
-
};
|
|
2920
|
-
var OpenPondTasksetPackageClient = class {
|
|
2921
|
-
#options;
|
|
2922
|
-
constructor(options) {
|
|
2923
|
-
const url = new URL(options.baseUrl);
|
|
2924
|
-
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.apiKey.trim() || !options.teamId.trim()) throw new Error("Taskset package client requires a clean HTTP(S) endpoint and workspace credentials.");
|
|
2925
|
-
this.#options = { ...options, baseUrl: url.toString().replace(/\/+$/, "") };
|
|
2926
|
-
}
|
|
2927
|
-
async publish(input, options = {}) {
|
|
2928
|
-
const request = TasksetPackagePublicationSchema.parse(input);
|
|
2929
|
-
validateTasksetPackage(request.package);
|
|
2930
|
-
const receipt = TasksetPackageReceiptSchema.parse(await this.#request("", "POST", request, options.signal));
|
|
2931
|
-
const release = request.package.taskset;
|
|
2932
|
-
if (receipt.teamId !== this.#options.teamId || receipt.modelProjectId !== request.modelProjectId || receipt.operationId !== request.operationId || receipt.packageHash !== request.package.contentHash || receipt.taskset.id !== release.id || receipt.taskset.revision !== release.revision || receipt.taskset.contentHash !== release.contentHash) {
|
|
2933
|
-
throw new OpenPondTasksetPackageError(502, "package_receipt_mismatch", "Taskset publication receipt did not match the requested package and owner.");
|
|
2934
|
-
}
|
|
2935
|
-
if (request.selection !== void 0 && receipt.selection !== request.selection) throw new OpenPondTasksetPackageError(502, "package_receipt_mismatch", "Taskset publication did not retain its selection mode.");
|
|
2936
|
-
if (request.selection === "attach" && receipt.projectEtag !== request.expectedProjectEtag) throw new OpenPondTasksetPackageError(502, "package_receipt_mismatch", "Attaching a historical Taskset changed the Model configuration.");
|
|
2937
|
-
if (request.modelConfiguration) {
|
|
2938
|
-
const expected = request.modelConfiguration;
|
|
2939
|
-
const project = receipt.project;
|
|
2940
|
-
const binding = tasksetPackageRewardBinding(request.package);
|
|
2941
|
-
const setup = HostedModelProjectTrainingSetupSchema.parse({
|
|
2942
|
-
...expected.trainingSetup,
|
|
2943
|
-
tasksetRef: learningRef4(release),
|
|
2944
|
-
rewardBindingRef: binding ? learningRef4(binding) : null,
|
|
2945
|
-
tasksetRelease: null,
|
|
2946
|
-
recipe: null
|
|
2947
|
-
});
|
|
2948
|
-
if (!project || project.teamId !== this.#options.teamId || project.etag !== receipt.projectEtag || ![project.id, project.portableProjectId].includes(request.modelProjectId) || project.portableProjectId !== expected.portableProjectId || project.name !== expected.name || project.objective !== expected.objective || project.sourceRevision !== expected.sourceRevision || Date.parse(project.sourceUpdatedAt) !== Date.parse(expected.sourceUpdatedAt) || contentHash(project.defaultBaseModel) !== contentHash(expected.defaultBaseModel) || project.defaultDestinationId !== expected.defaultDestinationId || contentHash(project.trainingSetup) !== contentHash(setup)) {
|
|
2949
|
-
throw new OpenPondTasksetPackageError(502, "package_receipt_mismatch", "Taskset publication did not retain the requested Model configuration.");
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
return receipt;
|
|
2953
|
-
}
|
|
2954
|
-
async get(modelProjectId, reference, options = {}) {
|
|
2955
|
-
const project = IdSchema5.parse(modelProjectId);
|
|
2956
|
-
const ref = TasksetCatalogReleaseRefSchema.parse(reference);
|
|
2957
|
-
const expectedPackageHash = options.expectedPackageHash === void 0 ? void 0 : HashSchema6.parse(options.expectedPackageHash);
|
|
2958
|
-
const response = TasksetPackageReadbackSchema.parse(await this.#request(`/${encodeURIComponent(project)}/${encodeURIComponent(ref.id)}/${ref.revision}/${ref.contentHash}`, "GET", void 0, options.signal));
|
|
2959
|
-
const taskset = response.package.taskset;
|
|
2960
|
-
if (response.teamId !== this.#options.teamId || response.modelProjectId !== project || taskset.id !== ref.id || taskset.revision !== ref.revision || taskset.contentHash !== ref.contentHash) throw new OpenPondTasksetPackageError(502, "package_readback_mismatch", "Taskset package did not match the requested release and owner.");
|
|
2961
|
-
if (expectedPackageHash !== void 0 && response.package.contentHash !== expectedPackageHash) throw new OpenPondTasksetPackageError(502, "package_readback_mismatch", "Taskset package did not match the saved publication receipt.");
|
|
2962
|
-
return validateTasksetPackage(response.package);
|
|
2963
|
-
}
|
|
2964
|
-
async #request(path, method, body, signal) {
|
|
2965
|
-
const serialized = body === void 0 ? void 0 : JSON.stringify(body);
|
|
2966
|
-
if (serialized && new TextEncoder().encode(serialized).byteLength > MAX_TASKSET_PACKAGE_BYTES) throw new OpenPondTasksetPackageError(413, "package_too_large", "Taskset publication exceeds the 64 MiB envelope.");
|
|
2967
|
-
const response = await (this.#options.fetch ?? globalThis.fetch)(`${this.#options.baseUrl}/v1/taskset-packages${path}`, {
|
|
2968
|
-
method,
|
|
2969
|
-
headers: { Authorization: `Bearer ${this.#options.apiKey}`, "X-OpenPond-Team-Id": this.#options.teamId, Accept: "application/json", ...serialized ? { "Content-Type": "application/json" } : {} },
|
|
2970
|
-
body: serialized,
|
|
2971
|
-
signal,
|
|
2972
|
-
redirect: "error"
|
|
2973
|
-
});
|
|
2974
|
-
const reader = response.body?.getReader();
|
|
2975
|
-
if (!reader) throw new OpenPondTasksetPackageError(response.status, "empty_response", "Taskset package response was empty.");
|
|
2976
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2977
|
-
let bytes = 0;
|
|
2978
|
-
let text = "";
|
|
2979
|
-
try {
|
|
2980
|
-
while (true) {
|
|
2981
|
-
const chunk = await reader.read();
|
|
2982
|
-
if (chunk.done) break;
|
|
2983
|
-
bytes += chunk.value.byteLength;
|
|
2984
|
-
if (bytes > MAX_TASKSET_PACKAGE_BYTES) throw new OpenPondTasksetPackageError(413, "package_too_large", "Taskset response exceeds the 64 MiB envelope.");
|
|
2985
|
-
text += decoder.decode(chunk.value, { stream: true });
|
|
2986
|
-
}
|
|
2987
|
-
text += decoder.decode();
|
|
2988
|
-
} finally {
|
|
2989
|
-
await reader.cancel();
|
|
2990
|
-
reader.releaseLock();
|
|
2991
|
-
}
|
|
2992
|
-
const payload = JSON.parse(text);
|
|
2993
|
-
if (!response.ok) {
|
|
2994
|
-
const error = z21.object({ code: z21.string(), message: z21.string() }).safeParse(payload);
|
|
2995
|
-
throw new OpenPondTasksetPackageError(response.status, error.success ? error.data.code : "package_request_failed", error.success ? error.data.message : `Taskset package request failed (${response.status}).`);
|
|
2996
|
-
}
|
|
2997
|
-
return payload;
|
|
2998
|
-
}
|
|
2999
|
-
};
|
|
2
|
+
ModelBatchReviewInspectionSchema,
|
|
3
|
+
ModelBatchReviewReceiptSchema,
|
|
4
|
+
ModelBatchReviewRequestSchema
|
|
5
|
+
} from "./chunk-K5ZCYOZO.js";
|
|
6
|
+
import {
|
|
7
|
+
GraderFixtureSchema,
|
|
8
|
+
GraderSpecSchema,
|
|
9
|
+
MAX_TASKSET_PACKAGE_BYTES,
|
|
10
|
+
OpenPondTasksetPackageClient,
|
|
11
|
+
OpenPondTasksetPackageError,
|
|
12
|
+
TasksetDraftSchema,
|
|
13
|
+
TasksetEnvironmentResourceSchema,
|
|
14
|
+
TasksetPackageContentSchema,
|
|
15
|
+
TasksetPackageFileSchema,
|
|
16
|
+
TasksetPackageLearningResourcesSchema,
|
|
17
|
+
TasksetPackageModelConfigurationSchema,
|
|
18
|
+
TasksetPackagePublicationSchema,
|
|
19
|
+
TasksetPackageReadbackSchema,
|
|
20
|
+
TasksetPackageReceiptSchema,
|
|
21
|
+
TasksetPackageSchema,
|
|
22
|
+
TasksetSchema,
|
|
23
|
+
TasksetSourceRefSchema,
|
|
24
|
+
assertModelTasksetAuthoring,
|
|
25
|
+
computeTasksetHash,
|
|
26
|
+
configuredTasksetDraftFiles,
|
|
27
|
+
createTasksetDraft,
|
|
28
|
+
createTasksetDraftWorkspace,
|
|
29
|
+
createTasksetPackage,
|
|
30
|
+
createTasksetPackageExecutionFile,
|
|
31
|
+
decodeTasksetDraftWorkspaceFile,
|
|
32
|
+
decodeTasksetPackageFile,
|
|
33
|
+
isManagedTasksetDraftFilePath,
|
|
34
|
+
learningPackageContextFiles,
|
|
35
|
+
modelAuthoredTasksetId,
|
|
36
|
+
publishTasksetDraft,
|
|
37
|
+
renderTasksetDraftManifests,
|
|
38
|
+
resolveTasksetPackageExecution,
|
|
39
|
+
resolveTasksetPackageInstructions,
|
|
40
|
+
tasksetPackageRewardBinding,
|
|
41
|
+
validateTasksetDraftWorkspace,
|
|
42
|
+
validateTasksetLearningResources,
|
|
43
|
+
validateTasksetPackage
|
|
44
|
+
} from "./chunk-AZUCY3E5.js";
|
|
45
|
+
import {
|
|
46
|
+
ModelTasksetAuthoringOwnerSchema,
|
|
47
|
+
ModelTasksetAuthoringSchema,
|
|
48
|
+
ModelTasksetDraftPreparationSchema,
|
|
49
|
+
ModelTasksetDraftRequestSchema,
|
|
50
|
+
TasksetDraftFileContentSchema,
|
|
51
|
+
TasksetDraftFileInfoSchema,
|
|
52
|
+
TasksetDraftFileMutationSchema,
|
|
53
|
+
TasksetDraftFilePathSchema,
|
|
54
|
+
TasksetDraftFileSchema
|
|
55
|
+
} from "./chunk-S7I45WJQ.js";
|
|
56
|
+
import "./chunk-AVW35YOH.js";
|
|
57
|
+
import "./chunk-A4ZDOZKP.js";
|
|
58
|
+
import {
|
|
59
|
+
ModelStarterExecutionSchema,
|
|
60
|
+
modelStarterExecutionAssetId
|
|
61
|
+
} from "./chunk-65D4C7HP.js";
|
|
62
|
+
import {
|
|
63
|
+
CapabilityRequirementSchema,
|
|
64
|
+
ToolDeclarationSchema
|
|
65
|
+
} from "./chunk-IVEXCIHO.js";
|
|
66
|
+
import {
|
|
67
|
+
ImmutableAssetRefSchema,
|
|
68
|
+
contentHash,
|
|
69
|
+
sha256
|
|
70
|
+
} from "./chunk-ZPCK222K.js";
|
|
71
|
+
import "./chunk-5PRP457R.js";
|
|
3000
72
|
|
|
3001
73
|
// src/model-batch-review.ts
|
|
3002
74
|
import {
|
|
3003
75
|
LearningDomainError as LearningDomainError2,
|
|
3004
|
-
learningRef as
|
|
3005
|
-
sameLearningRef as
|
|
76
|
+
learningRef as learningRef2,
|
|
77
|
+
sameLearningRef as sameLearningRef2,
|
|
3006
78
|
requireLearningRelease,
|
|
3007
79
|
requireLearningResource,
|
|
3008
|
-
taskBatchPackageMetadata as
|
|
80
|
+
taskBatchPackageMetadata as taskBatchPackageMetadata2
|
|
3009
81
|
} from "@openpond/evals/learning";
|
|
3010
82
|
|
|
3011
|
-
// src/model-batch-review-contracts.ts
|
|
3012
|
-
import { z as z22 } from "zod";
|
|
3013
|
-
import { LearningJsonObjectSchema, LearningRevisionRefSchema as LearningRevisionRefSchema2, LearningSourceSchema as LearningSourceSchema2, TaskEvidenceSchema as TaskEvidenceSchema2, TaskFeedbackSchema, TaskDefinitionSchema as TaskDefinitionSchema2, TaskAdmissionDecisionSchema as TaskAdmissionDecisionSchema2 } from "@openpond/evals/learning";
|
|
3014
|
-
import { RewardBindingSchema as RewardBindingSchema2 } from "@openpond/evals/rewards";
|
|
3015
|
-
var ReleaseIdSchema2 = LearningRevisionRefSchema2.shape.id;
|
|
3016
|
-
var ModelBatchReviewInspectionSchema = z22.object({
|
|
3017
|
-
schemaVersion: z22.literal("openpond.modelBatchReviewInspection.v1"),
|
|
3018
|
-
packageHash: z22.string().regex(/^[a-f0-9]{64}$/),
|
|
3019
|
-
definition: TaskDefinitionSchema2,
|
|
3020
|
-
binding: RewardBindingSchema2,
|
|
3021
|
-
evidence: z22.array(TaskEvidenceSchema2).min(1).max(1e4),
|
|
3022
|
-
decisions: z22.array(TaskAdmissionDecisionSchema2).min(1).max(1e4)
|
|
3023
|
-
}).strict();
|
|
3024
|
-
var ModelBatchReviewRequestSchema = z22.object({
|
|
3025
|
-
schemaVersion: z22.literal("openpond.modelBatchReviewRequest.v1"),
|
|
3026
|
-
operationId: ReleaseIdSchema2,
|
|
3027
|
-
modelId: ReleaseIdSchema2,
|
|
3028
|
-
expectedModelRevision: z22.number().int().positive(),
|
|
3029
|
-
tasksetRef: LearningRevisionRefSchema2,
|
|
3030
|
-
rewardBindingRef: LearningRevisionRefSchema2.nullable(),
|
|
3031
|
-
definition: z22.object({
|
|
3032
|
-
name: z22.string().trim().min(1).max(500).optional(),
|
|
3033
|
-
instructions: z22.string().trim().min(1).max(2e4).optional(),
|
|
3034
|
-
inputSchema: LearningJsonObjectSchema.optional(),
|
|
3035
|
-
outputSchema: LearningJsonObjectSchema.optional()
|
|
3036
|
-
}).strict(),
|
|
3037
|
-
examples: z22.array(z22.object({
|
|
3038
|
-
evidence: LearningRevisionRefSchema2,
|
|
3039
|
-
input: LearningJsonObjectSchema.optional(),
|
|
3040
|
-
expected: LearningJsonObjectSchema.nullable().optional(),
|
|
3041
|
-
evaluatorContext: LearningJsonObjectSchema.nullable().optional(),
|
|
3042
|
-
proposedTarget: LearningJsonObjectSchema.nullable().optional()
|
|
3043
|
-
}).strict()).max(1e4)
|
|
3044
|
-
}).strict();
|
|
3045
|
-
var ModelBatchReviewReceiptSchema = z22.object({
|
|
3046
|
-
schemaVersion: z22.literal("openpond.modelBatchReviewReceipt.v1"),
|
|
3047
|
-
operationId: ReleaseIdSchema2,
|
|
3048
|
-
modelId: ReleaseIdSchema2,
|
|
3049
|
-
source: LearningSourceSchema2,
|
|
3050
|
-
evidence: z22.array(TaskEvidenceSchema2).min(1).max(1e4),
|
|
3051
|
-
proposals: z22.array(TaskFeedbackSchema).max(1e4)
|
|
3052
|
-
}).strict();
|
|
3053
|
-
|
|
3054
83
|
// src/model-batch-review-preparation.ts
|
|
3055
84
|
import {
|
|
3056
85
|
LearningDomainError,
|
|
3057
|
-
LearningSourceSchema
|
|
3058
|
-
TaskDefinitionSchema
|
|
3059
|
-
TaskEvidenceSchema
|
|
3060
|
-
TaskFeedbackSchema
|
|
3061
|
-
assertLearningContentHash
|
|
86
|
+
LearningSourceSchema,
|
|
87
|
+
TaskDefinitionSchema,
|
|
88
|
+
TaskEvidenceSchema,
|
|
89
|
+
TaskFeedbackSchema,
|
|
90
|
+
assertLearningContentHash,
|
|
3062
91
|
learningEvidenceId,
|
|
3063
|
-
learningRef
|
|
3064
|
-
sameLearningRef
|
|
3065
|
-
sealLearningContent
|
|
3066
|
-
taskBatchPackageMetadata
|
|
3067
|
-
verifyLearningTextAsset
|
|
92
|
+
learningRef,
|
|
93
|
+
sameLearningRef,
|
|
94
|
+
sealLearningContent,
|
|
95
|
+
taskBatchPackageMetadata,
|
|
96
|
+
verifyLearningTextAsset
|
|
3068
97
|
} from "@openpond/evals/learning";
|
|
3069
|
-
import { compileBoundGraders
|
|
98
|
+
import { compileBoundGraders, createRewardBinding, createRewardRelease, resolveBoundRewards } from "@openpond/evals/rewards";
|
|
3070
99
|
function prepareModelBatchReview(input) {
|
|
3071
100
|
const { request, package: value } = input;
|
|
3072
101
|
const learning = value.learningResources;
|
|
3073
102
|
if (!learning) throw new LearningDomainError("model_review_batch_required", 422);
|
|
3074
|
-
const metadata =
|
|
103
|
+
const metadata = taskBatchPackageMetadata(value.taskset);
|
|
3075
104
|
const id = `model-review-${contentHash([input.scope, request.modelId, request.operationId])}`;
|
|
3076
105
|
const edits = new Map(request.examples.map((edit) => [contentHash(edit.evidence), edit]));
|
|
3077
|
-
const parentRefs = new Set(learning.evidence.map((evidence2) => contentHash(
|
|
106
|
+
const parentRefs = new Set(learning.evidence.map((evidence2) => contentHash(learningRef(evidence2))));
|
|
3078
107
|
const decisions = new Map(learning.decisions.map((decision) => [contentHash(decision.evidence), decision]));
|
|
3079
108
|
if (edits.size !== request.examples.length || request.examples.some((edit) => !parentRefs.has(contentHash(edit.evidence)))) {
|
|
3080
109
|
throw new LearningDomainError("model_review_evidence_mismatch", 409);
|
|
3081
110
|
}
|
|
3082
|
-
for (const resource of [input.binding, ...input.rewards, ...input.assets])
|
|
111
|
+
for (const resource of [input.binding, ...input.rewards, ...input.assets]) assertLearningContentHash(resource);
|
|
3083
112
|
resolveBoundRewards(input.binding, input.rewards);
|
|
3084
113
|
const rewardByHash = /* @__PURE__ */ new Map();
|
|
3085
114
|
for (const source2 of input.binding.sources) {
|
|
3086
|
-
const original = input.rewards.find((reward) =>
|
|
115
|
+
const original = input.rewards.find((reward) => sameLearningRef(learningRef(reward), source2.reward));
|
|
3087
116
|
const { contentHash: _hash, ...content } = original;
|
|
3088
117
|
rewardByHash.set(original.contentHash, createRewardRelease({ ...content, id: `${id}-reward-${original.contentHash}`, revision: 1 }));
|
|
3089
118
|
}
|
|
@@ -3093,7 +122,7 @@ function prepareModelBatchReview(input) {
|
|
|
3093
122
|
...bindingContent,
|
|
3094
123
|
id: `${id}-binding`,
|
|
3095
124
|
revision: 1,
|
|
3096
|
-
sources: input.binding.sources.map((source2) => ({ ...source2, reward:
|
|
125
|
+
sources: input.binding.sources.map((source2) => ({ ...source2, reward: learningRef(rewardByHash.get(source2.reward.contentHash)) }))
|
|
3097
126
|
}, rewards);
|
|
3098
127
|
const assetRefs = rewards.flatMap((reward) => [
|
|
3099
128
|
...reward.assets,
|
|
@@ -3104,30 +133,30 @@ function prepareModelBatchReview(input) {
|
|
|
3104
133
|
const assets = [...new Map(assetRefs.map((ref) => {
|
|
3105
134
|
const asset = input.assets.find((asset2) => asset2.id === ref.id);
|
|
3106
135
|
if (!asset) throw new LearningDomainError("model_review_reward_asset_missing", 422);
|
|
3107
|
-
|
|
136
|
+
verifyLearningTextAsset(asset, ref);
|
|
3108
137
|
if (ref.visibility === "policy") throw new LearningDomainError("reward_asset_visibility_invalid", 422);
|
|
3109
138
|
return [asset.id, asset];
|
|
3110
139
|
})).values()];
|
|
3111
140
|
const { environmentRelease: _environment, verifierSetRelease: _verifiers, ...execution } = metadata.definition.execution;
|
|
3112
141
|
const { contentHash: _definitionHash, ...definitionContent } = metadata.definition;
|
|
3113
|
-
const definition =
|
|
142
|
+
const definition = TaskDefinitionSchema.parse(sealLearningContent({
|
|
3114
143
|
...definitionContent,
|
|
3115
144
|
...request.definition,
|
|
3116
145
|
id: `${id}-definition`,
|
|
3117
146
|
revision: 1,
|
|
3118
|
-
rewardBinding:
|
|
147
|
+
rewardBinding: learningRef(binding),
|
|
3119
148
|
execution: {
|
|
3120
149
|
...execution,
|
|
3121
|
-
policy: { ...execution.policy, hiddenGraderRefs:
|
|
150
|
+
policy: { ...execution.policy, hiddenGraderRefs: compileBoundGraders(binding, rewards).filter((grader) => grader.privileged).map((grader) => grader.id) }
|
|
3122
151
|
}
|
|
3123
152
|
}));
|
|
3124
|
-
const source =
|
|
153
|
+
const source = LearningSourceSchema.parse(sealLearningContent({
|
|
3125
154
|
schemaVersion: "openpond.learningSource.v1",
|
|
3126
155
|
id,
|
|
3127
156
|
revision: 1,
|
|
3128
157
|
name: `${definition.name} review`,
|
|
3129
158
|
kind: "direct",
|
|
3130
|
-
taskDefinition:
|
|
159
|
+
taskDefinition: learningRef(definition),
|
|
3131
160
|
enabled: true,
|
|
3132
161
|
allowedSplits: [...new Set(learning.evidence.map((item) => item.submission.split))],
|
|
3133
162
|
mapping: null,
|
|
@@ -3135,13 +164,13 @@ function prepareModelBatchReview(input) {
|
|
|
3135
164
|
reviewOrigin: {
|
|
3136
165
|
modelId: request.modelId,
|
|
3137
166
|
packageHash: value.contentHash,
|
|
3138
|
-
taskset:
|
|
3139
|
-
batch:
|
|
3140
|
-
rewardBinding:
|
|
167
|
+
taskset: learningRef(value.taskset),
|
|
168
|
+
batch: learningRef(learning.batch),
|
|
169
|
+
rewardBinding: learningRef(input.binding)
|
|
3141
170
|
}
|
|
3142
171
|
}));
|
|
3143
172
|
const evidence = learning.evidence.map((parent) => {
|
|
3144
|
-
const edit = edits.get(contentHash(
|
|
173
|
+
const edit = edits.get(contentHash(learningRef(parent)));
|
|
3145
174
|
const attemptId = `review-${parent.contentHash}`;
|
|
3146
175
|
const policyChanged = contentHash({
|
|
3147
176
|
instructions: definition.instructions,
|
|
@@ -3154,15 +183,15 @@ function prepareModelBatchReview(input) {
|
|
|
3154
183
|
outputSchema: metadata.definition.outputSchema,
|
|
3155
184
|
input: parent.submission.input
|
|
3156
185
|
});
|
|
3157
|
-
return
|
|
186
|
+
return TaskEvidenceSchema.parse(sealLearningContent({
|
|
3158
187
|
schemaVersion: "openpond.taskEvidence.v1",
|
|
3159
188
|
id: learningEvidenceId(source.id, parent.submission.exampleId, attemptId),
|
|
3160
189
|
revision: 1,
|
|
3161
|
-
source:
|
|
190
|
+
source: learningRef(source),
|
|
3162
191
|
submission: {
|
|
3163
192
|
...parent.submission,
|
|
3164
193
|
sourceId: source.id,
|
|
3165
|
-
taskDefinition:
|
|
194
|
+
taskDefinition: learningRef(definition),
|
|
3166
195
|
attemptId,
|
|
3167
196
|
// The old response was observed under the old policy-visible task. Its
|
|
3168
197
|
// parent snapshot remains available, but it is not a run of new inputs.
|
|
@@ -3172,7 +201,7 @@ function prepareModelBatchReview(input) {
|
|
|
3172
201
|
...edit?.expected === void 0 ? {} : { expected: edit.expected },
|
|
3173
202
|
...edit?.evaluatorContext === void 0 ? {} : { evaluatorContext: edit.evaluatorContext }
|
|
3174
203
|
},
|
|
3175
|
-
supersedes:
|
|
204
|
+
supersedes: learningRef(parent),
|
|
3176
205
|
correctionFeedbackId: null,
|
|
3177
206
|
receivedAt: input.now
|
|
3178
207
|
}));
|
|
@@ -3181,7 +210,7 @@ function prepareModelBatchReview(input) {
|
|
|
3181
210
|
const edit = edits.get(contentHash(item.supersedes));
|
|
3182
211
|
const decision = decisions.get(contentHash(item.supersedes));
|
|
3183
212
|
const target = edit?.proposedTarget === void 0 ? decision.approvedTarget : edit.proposedTarget;
|
|
3184
|
-
return target === null ? [] : [
|
|
213
|
+
return target === null ? [] : [TaskFeedbackSchema.parse({
|
|
3185
214
|
schemaVersion: "openpond.taskFeedbackRecord.v1",
|
|
3186
215
|
id: `feedback-${contentHash([id, item.id])}`,
|
|
3187
216
|
revision: 1,
|
|
@@ -3198,7 +227,7 @@ function prepareModelBatchReview(input) {
|
|
|
3198
227
|
note: "Proposed target for the revised task. Grade and review before admission."
|
|
3199
228
|
},
|
|
3200
229
|
status: "pending_review",
|
|
3201
|
-
evidence:
|
|
230
|
+
evidence: learningRef(item),
|
|
3202
231
|
createdAt: input.now,
|
|
3203
232
|
review: null
|
|
3204
233
|
})];
|
|
@@ -3212,7 +241,7 @@ var operation = (request) => `model-batch-review-${contentHash([request.modelId,
|
|
|
3212
241
|
function inspectModelBatchPackage(raw) {
|
|
3213
242
|
const value = validateTasksetPackage(raw);
|
|
3214
243
|
if (!value.learningResources) throw new LearningDomainError2("model_review_batch_required", 422);
|
|
3215
|
-
const metadata =
|
|
244
|
+
const metadata = taskBatchPackageMetadata2(value.taskset);
|
|
3216
245
|
return ModelBatchReviewInspectionSchema.parse({
|
|
3217
246
|
schemaVersion: "openpond.modelBatchReviewInspection.v1",
|
|
3218
247
|
packageHash: value.contentHash,
|
|
@@ -3235,9 +264,9 @@ async function beginModelBatchReview(transaction, input) {
|
|
|
3235
264
|
if (prior) return prior;
|
|
3236
265
|
const value = validateTasksetPackage(input.package);
|
|
3237
266
|
if (!value.learningResources) throw new LearningDomainError2("model_review_batch_required", 422);
|
|
3238
|
-
const metadata =
|
|
267
|
+
const metadata = taskBatchPackageMetadata2(value.taskset);
|
|
3239
268
|
const selected = request.rewardBindingRef;
|
|
3240
|
-
const retained = !selected ||
|
|
269
|
+
const retained = !selected || sameLearningRef2(selected, learningRef2(metadata.binding));
|
|
3241
270
|
const binding = retained ? metadata.binding : await requireLearningRelease(transaction, "binding", selected);
|
|
3242
271
|
const rewards = retained ? metadata.rewards : await Promise.all(binding.sources.map((source) => requireLearningRelease(transaction, "reward", source.reward)));
|
|
3243
272
|
const assetIds = new Set(rewards.flatMap((reward) => [
|
|
@@ -3283,9 +312,9 @@ async function readReceipt(transaction, request, pointers) {
|
|
|
3283
312
|
}
|
|
3284
313
|
|
|
3285
314
|
// src/model-taskset-authoring.ts
|
|
3286
|
-
import { createVerifierSetRelease
|
|
3287
|
-
import { learningRef as
|
|
3288
|
-
import { TasksetReleaseSchema
|
|
315
|
+
import { createVerifierSetRelease } from "@openpond/evals";
|
|
316
|
+
import { learningRef as learningRef3, sameLearningRef as sameLearningRef3, sealLearningContent as sealLearningContent2 } from "@openpond/evals/learning";
|
|
317
|
+
import { TasksetReleaseSchema } from "@openpond/evals/tasksets";
|
|
3289
318
|
function prepareModelTasksetDraft(input) {
|
|
3290
319
|
const request = ModelTasksetDraftRequestSchema.parse(input.request);
|
|
3291
320
|
const owner = ModelTasksetAuthoringOwnerSchema.parse(input.owner);
|
|
@@ -3293,14 +322,14 @@ function prepareModelTasksetDraft(input) {
|
|
|
3293
322
|
if (source.contentHash !== request.sourcePackageHash) throw new Error("Taskset draft source package changed.");
|
|
3294
323
|
const previous = assertModelTasksetAuthoring(source.taskset);
|
|
3295
324
|
const owned = previous && contentHash(previous.owner) === contentHash(owner);
|
|
3296
|
-
const root = owned ? previous.root :
|
|
3297
|
-
const lineage = { schemaVersion: "openpond.modelTasksetAuthoring.v1", owner, root, parent:
|
|
325
|
+
const root = owned ? previous.root : learningRef3(source.taskset);
|
|
326
|
+
const lineage = { schemaVersion: "openpond.modelTasksetAuthoring.v1", owner, root, parent: learningRef3(source.taskset) };
|
|
3298
327
|
return ModelTasksetDraftPreparationSchema.parse({
|
|
3299
328
|
schemaVersion: "openpond.modelTasksetDraftPreparation.v1",
|
|
3300
329
|
draftId: `model-taskset-draft-${contentHash({ owner, operationId: request.operationId })}`,
|
|
3301
330
|
requestHash: contentHash(request),
|
|
3302
331
|
sourcePackageHash: source.contentHash,
|
|
3303
|
-
sourceTasksetRef:
|
|
332
|
+
sourceTasksetRef: learningRef3(source.taskset),
|
|
3304
333
|
tasksetId: modelAuthoredTasksetId(lineage),
|
|
3305
334
|
tasksetRevision: owned ? source.taskset.revision + 1 : 1,
|
|
3306
335
|
lineage
|
|
@@ -3308,18 +337,18 @@ function prepareModelTasksetDraft(input) {
|
|
|
3308
337
|
}
|
|
3309
338
|
function publishModelTasksetDraftPackage(input) {
|
|
3310
339
|
const prepared = ModelTasksetDraftPreparationSchema.parse(input.preparation);
|
|
3311
|
-
if (!
|
|
340
|
+
if (!sameLearningRef3(prepared.sourceTasksetRef, prepared.lineage.parent)) throw new Error("Taskset draft preparation differs from its source lineage.");
|
|
3312
341
|
const edited = requireOrdinaryPackage(input.edited);
|
|
3313
342
|
const { contentHash: _verifierHash, ...verifierContent } = edited.verifierSet;
|
|
3314
|
-
const verifierSet =
|
|
343
|
+
const verifierSet = createVerifierSetRelease({
|
|
3315
344
|
...verifierContent,
|
|
3316
345
|
id: `${prepared.tasksetId}-verifiers`,
|
|
3317
346
|
revision: prepared.tasksetRevision,
|
|
3318
347
|
calibrationReceiptRefs: [],
|
|
3319
|
-
metadata: { sourceVerifierSet:
|
|
348
|
+
metadata: { sourceVerifierSet: learningRef3(edited.verifierSet) }
|
|
3320
349
|
});
|
|
3321
350
|
const { contentHash: _hash, ...content } = edited.taskset;
|
|
3322
|
-
const taskset =
|
|
351
|
+
const taskset = TasksetReleaseSchema.parse(sealLearningContent2({
|
|
3323
352
|
...content,
|
|
3324
353
|
id: prepared.tasksetId,
|
|
3325
354
|
revision: prepared.tasksetRevision,
|
|
@@ -3342,7 +371,819 @@ function requireOrdinaryPackage(value) {
|
|
|
3342
371
|
if (result.modelResources || result.learningResources) throw new Error("This Taskset requires its bound or reviewed authoring workflow.");
|
|
3343
372
|
return result;
|
|
3344
373
|
}
|
|
374
|
+
|
|
375
|
+
// src/taskset-authored-portable-release.ts
|
|
376
|
+
import {
|
|
377
|
+
TaskRecordSchema,
|
|
378
|
+
GraderSpecSchema as PortableGraderSpecSchema,
|
|
379
|
+
TasksetReleaseContentSchema,
|
|
380
|
+
TasksetReleaseSchema as TasksetReleaseSchema2,
|
|
381
|
+
bindTasksetExecutionReleases,
|
|
382
|
+
createEnvironmentRelease,
|
|
383
|
+
createVerifierSetRelease as createVerifierSetRelease2,
|
|
384
|
+
EnvironmentReleaseSchema,
|
|
385
|
+
VerifierSetReleaseSchema,
|
|
386
|
+
verifyEnvironmentRelease,
|
|
387
|
+
verifyVerifierSetRelease,
|
|
388
|
+
verifyPreferenceComparisonRelease
|
|
389
|
+
} from "@openpond/evals";
|
|
390
|
+
import { TaskBatchPackageMetadataSchema } from "@openpond/evals/learning";
|
|
391
|
+
import { compileBoundGraders as compileBoundGraders2, RewardBindingSchema, RewardReleaseSchema } from "@openpond/evals/rewards";
|
|
392
|
+
import { portableDeterministicCheck } from "@openpond/evals/graders";
|
|
393
|
+
function resolvePortableTasksetRewardExecution(taskset, supplied) {
|
|
394
|
+
const learning = taskset.metadata.learning === void 0 ? null : TaskBatchPackageMetadataSchema.parse(taskset.metadata.learning);
|
|
395
|
+
const embedded = taskset.metadata.rewardExecution;
|
|
396
|
+
const execution = supplied ?? (embedded ? {
|
|
397
|
+
binding: RewardBindingSchema.parse(embedded.binding),
|
|
398
|
+
rewards: RewardReleaseSchema.array().parse(embedded.rewards)
|
|
399
|
+
} : learning);
|
|
400
|
+
if (taskset.metadata.rewardBinding !== void 0) {
|
|
401
|
+
const reference = taskset.metadata.rewardBinding;
|
|
402
|
+
if (!execution || !reference || reference.id !== execution.binding.id || reference.revision !== execution.binding.revision || reference.contentHash !== execution.binding.contentHash) {
|
|
403
|
+
throw new Error("Portable Taskset requires its exact published Reward binding.");
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (execution) compileBoundGraders2(execution.binding, execution.rewards);
|
|
407
|
+
return execution ? { binding: execution.binding, rewards: execution.rewards } : null;
|
|
408
|
+
}
|
|
409
|
+
function materializePortableTasksetRelease(input) {
|
|
410
|
+
const environment = portableEnvironment(input.taskset);
|
|
411
|
+
const tools = portableTools(input.taskset);
|
|
412
|
+
const learning = input.taskset.metadata.learning === void 0 ? null : TaskBatchPackageMetadataSchema.parse(input.taskset.metadata.learning);
|
|
413
|
+
const embedded = input.taskset.metadata.rewardExecution;
|
|
414
|
+
const rewardExecution = resolvePortableTasksetRewardExecution(input.taskset, input.rewardExecution);
|
|
415
|
+
const graders = rewardExecution ? compileBoundGraders2(rewardExecution.binding, rewardExecution.rewards) : input.taskset.graders.map(portableGrader);
|
|
416
|
+
const tasks = input.selectedTasks?.length ? input.selectedTasks : input.taskset.tasks;
|
|
417
|
+
if (!tasks.length) throw new Error("A portable Taskset release requires at least one task.");
|
|
418
|
+
const pinned = input.taskset.environment.metadata.portableExecutionResources;
|
|
419
|
+
if (environment.entrypoint === "openpond.javascript-environment.v1" && !pinned) throw new Error("Tool Taskset publication requires its pinned execution resources.");
|
|
420
|
+
const environmentRelease = pinned ? EnvironmentReleaseSchema.parse(pinned.environment) : createEnvironmentRelease({
|
|
421
|
+
schemaVersion: "openpond.environmentRelease.v1",
|
|
422
|
+
id: `environment-release-${input.taskset.id}-r${input.taskset.revision}`,
|
|
423
|
+
revision: input.taskset.revision,
|
|
424
|
+
contract: environment,
|
|
425
|
+
actionSchemaRef: null,
|
|
426
|
+
observationSchemaRef: null,
|
|
427
|
+
stateSchemaRef: null,
|
|
428
|
+
artifactCollection: {
|
|
429
|
+
maxArtifacts: 1e5,
|
|
430
|
+
maxTotalBytes: 25e7
|
|
431
|
+
},
|
|
432
|
+
adapterConformanceHashes: {
|
|
433
|
+
[input.adapterId]: contentHash({ adapterId: input.adapterId, environment, tools })
|
|
434
|
+
},
|
|
435
|
+
metadata: {
|
|
436
|
+
sourceTasksetId: input.taskset.id,
|
|
437
|
+
sourcePackageHash: input.taskset.metadata.sourcePackageHash ?? null,
|
|
438
|
+
resources: input.taskset.environment.resources ?? []
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
const verifierSetRelease = pinned?.verifierSet !== void 0 ? VerifierSetReleaseSchema.parse(pinned.verifierSet) : createVerifierSetRelease2({
|
|
442
|
+
schemaVersion: "openpond.verifierSetRelease.v1",
|
|
443
|
+
id: `verifier-set-release-${input.taskset.id}-r${input.taskset.revision}`,
|
|
444
|
+
revision: input.taskset.revision,
|
|
445
|
+
graders,
|
|
446
|
+
isolation: {
|
|
447
|
+
processBoundary: "isolated_process",
|
|
448
|
+
networkPolicy: "none",
|
|
449
|
+
defaultTimeoutMs: Math.min(input.taskset.environment.defaultTimeoutMs, 3e5)
|
|
450
|
+
},
|
|
451
|
+
calibrationReceiptRefs: [],
|
|
452
|
+
metadata: { sourceTasksetId: input.taskset.id }
|
|
453
|
+
});
|
|
454
|
+
if (!verifyEnvironmentRelease(environmentRelease) || !verifyVerifierSetRelease(verifierSetRelease) || contentHash(environmentRelease.contract) !== contentHash(environment) || contentHash(verifierSetRelease.graders) !== contentHash(graders)) {
|
|
455
|
+
throw new Error("Taskset execution resources differ from its declared environment or graders.");
|
|
456
|
+
}
|
|
457
|
+
const tasksetContent = TasksetReleaseContentSchema.parse({
|
|
458
|
+
schemaVersion: "openpond.tasksetRelease.v2",
|
|
459
|
+
id: input.taskset.metadata.derivedPortableMetadata === void 0 ? `taskset-release-${input.taskset.id}-r${input.taskset.revision}` : input.taskset.id,
|
|
460
|
+
revision: input.taskset.revision,
|
|
461
|
+
policy: {
|
|
462
|
+
policyVisibleFields: input.taskset.policy.policyVisibleFields,
|
|
463
|
+
privilegedFields: input.taskset.policy.privilegedFields,
|
|
464
|
+
hiddenGraderRefs: input.taskset.policy.hiddenGraderRefs,
|
|
465
|
+
connectedAppScopes: input.taskset.policy.connectedAppScopes
|
|
466
|
+
},
|
|
467
|
+
environment,
|
|
468
|
+
tools,
|
|
469
|
+
capabilities: portableCapabilities(input.taskset),
|
|
470
|
+
tasks: tasks.map(projectPortableTaskRecord),
|
|
471
|
+
graders,
|
|
472
|
+
...input.taskset.metrics ? { metrics: input.taskset.metrics } : {},
|
|
473
|
+
metadata: input.taskset.metadata.derivedPortableMetadata ?? {
|
|
474
|
+
sourceTasksetId: input.taskset.id,
|
|
475
|
+
sourceTasksetHash: input.taskset.contentHash,
|
|
476
|
+
sourcePackageHash: input.taskset.metadata.sourcePackageHash ?? null,
|
|
477
|
+
environmentResources: input.taskset.environment.resources ?? [],
|
|
478
|
+
ordinaryAuthoring: {
|
|
479
|
+
instructions: input.taskset.objective,
|
|
480
|
+
graderFixtures: input.taskset.graderFixtures,
|
|
481
|
+
judgeCalibrationFixtures: Object.fromEntries(input.taskset.graders.filter((grader) => grader.kind === "model_judge").map((grader) => [grader.id, grader.calibrationFixtureRefs]))
|
|
482
|
+
},
|
|
483
|
+
...learning ? { learning } : {},
|
|
484
|
+
...rewardExecution && (input.rewardExecution || embedded) ? { rewardExecution: { binding: rewardExecution.binding, rewards: rewardExecution.rewards } } : {}
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
const draft = input.admittedTasksetRelease ? TasksetReleaseSchema2.parse(input.admittedTasksetRelease) : TasksetReleaseSchema2.parse({
|
|
488
|
+
...tasksetContent,
|
|
489
|
+
contentHash: contentHash(tasksetContent)
|
|
490
|
+
});
|
|
491
|
+
const tasksetRelease = draft.environmentRelease ? assertReleaseBindings({ draft, environmentRelease, verifierSetRelease }) : bindTasksetExecutionReleases({
|
|
492
|
+
taskset: draft,
|
|
493
|
+
environment: environmentRelease,
|
|
494
|
+
verifierSet: verifierSetRelease
|
|
495
|
+
});
|
|
496
|
+
return { environmentRelease, verifierSetRelease, tasksetRelease };
|
|
497
|
+
}
|
|
498
|
+
function projectPreferenceComparisonRelease(input) {
|
|
499
|
+
if (!verifyPreferenceComparisonRelease(input.preferenceComparison)) {
|
|
500
|
+
throw new Error("Preference comparison release failed immutable content verification.");
|
|
501
|
+
}
|
|
502
|
+
const release = input.preferenceComparison;
|
|
503
|
+
if (release.tasksetRelease.id !== input.tasksetRelease.id || release.tasksetRelease.contentHash !== input.tasksetRelease.contentHash) {
|
|
504
|
+
throw new Error("Preference comparison release must reference the admitted portable Taskset release.");
|
|
505
|
+
}
|
|
506
|
+
return release;
|
|
507
|
+
}
|
|
508
|
+
function portableTasksetEnvironment(taskset) {
|
|
509
|
+
return portableEnvironment(taskset);
|
|
510
|
+
}
|
|
511
|
+
function portableTasksetTools(taskset) {
|
|
512
|
+
return portableTools(taskset);
|
|
513
|
+
}
|
|
514
|
+
function projectPortableTaskRecord(task) {
|
|
515
|
+
const admitted = task.metadata.portableTaskRecord;
|
|
516
|
+
if (admitted !== void 0) {
|
|
517
|
+
const original = TaskRecordSchema.parse(admitted);
|
|
518
|
+
const projected = TaskRecordSchema.parse({
|
|
519
|
+
...original,
|
|
520
|
+
id: task.id,
|
|
521
|
+
clusterKey: task.clusterKey,
|
|
522
|
+
split: task.split,
|
|
523
|
+
input: task.input,
|
|
524
|
+
expectedOutput: portableExpectedOutput(task),
|
|
525
|
+
policyVisibleContext: task.policyVisibleContext,
|
|
526
|
+
privilegedContextRef: task.privilegedContextRef,
|
|
527
|
+
tags: task.tags,
|
|
528
|
+
artifactRefs: task.assets === void 0 ? original.artifactRefs : task.assets.map((asset) => {
|
|
529
|
+
const previous = original.artifactRefs.find((item) => item.id === asset.id);
|
|
530
|
+
return {
|
|
531
|
+
id: asset.id,
|
|
532
|
+
path: previous?.path ?? `tasks/${segment(task.id)}/${segment(asset.fileName)}`,
|
|
533
|
+
contentHash: hash(asset.sha256),
|
|
534
|
+
sizeBytes: asset.sizeBytes,
|
|
535
|
+
mediaType: asset.mediaType,
|
|
536
|
+
visibility: previous?.visibility ?? "policy"
|
|
537
|
+
};
|
|
538
|
+
}),
|
|
539
|
+
requiredOutputs: task.requiredOutputs === void 0 ? original.requiredOutputs : task.requiredOutputs.map((output) => {
|
|
540
|
+
const previous = original.requiredOutputs?.find((item) => item.path === output.path);
|
|
541
|
+
return {
|
|
542
|
+
path: output.path,
|
|
543
|
+
mediaType: output.mediaType,
|
|
544
|
+
schemaRef: previous?.schemaRef && previous.schemaRef.id === output.schemaRef ? previous.schemaRef : null,
|
|
545
|
+
maxBytes: output.maxBytes ?? null,
|
|
546
|
+
metadata: {
|
|
547
|
+
...output.metadata,
|
|
548
|
+
...output.schemaRef && previous?.schemaRef?.id !== output.schemaRef ? { legacySchemaRef: output.schemaRef } : {}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
})
|
|
552
|
+
});
|
|
553
|
+
if (projected.requiredOutputs === void 0) delete projected.requiredOutputs;
|
|
554
|
+
return projected;
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
id: task.id,
|
|
558
|
+
clusterKey: task.clusterKey,
|
|
559
|
+
split: task.split,
|
|
560
|
+
input: task.input,
|
|
561
|
+
expectedOutput: portableExpectedOutput(task),
|
|
562
|
+
policyVisibleContext: task.policyVisibleContext,
|
|
563
|
+
privilegedContextRef: task.privilegedContextRef,
|
|
564
|
+
artifactRefs: (task.assets ?? []).map((item) => ({
|
|
565
|
+
id: item.id,
|
|
566
|
+
path: `tasks/${segment(task.id)}/${segment(item.fileName)}`,
|
|
567
|
+
contentHash: hash(item.sha256),
|
|
568
|
+
sizeBytes: item.sizeBytes,
|
|
569
|
+
mediaType: item.mediaType,
|
|
570
|
+
visibility: "policy"
|
|
571
|
+
})),
|
|
572
|
+
requiredOutputs: (task.requiredOutputs ?? []).map((output) => ({
|
|
573
|
+
path: output.path,
|
|
574
|
+
mediaType: output.mediaType,
|
|
575
|
+
schemaRef: null,
|
|
576
|
+
maxBytes: output.maxBytes ?? null,
|
|
577
|
+
metadata: {
|
|
578
|
+
...output.metadata,
|
|
579
|
+
legacySchemaRef: output.schemaRef ?? null
|
|
580
|
+
}
|
|
581
|
+
})),
|
|
582
|
+
tags: task.tags
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function portableExpectedOutput(task) {
|
|
586
|
+
if (!task.expectedOutput) return null;
|
|
587
|
+
if ("artifactRenderer" in task.expectedOutput) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`Task ${task.id} embeds an artifact renderer. Put shared renderer configuration in Environment resources and reference it from the Scenario.`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
return task.expectedOutput;
|
|
593
|
+
}
|
|
594
|
+
function portableEnvironment(taskset) {
|
|
595
|
+
const kind = taskset.environment.kind === "chat" ? "text" : taskset.environment.kind === "work" ? "work" : taskset.environment.kind === "program" ? "custom_program" : "agent";
|
|
596
|
+
return {
|
|
597
|
+
protocolVersion: "openpond.environment.v1",
|
|
598
|
+
kind,
|
|
599
|
+
entrypoint: taskset.environment.entrypoint,
|
|
600
|
+
stateful: taskset.environment.stateful,
|
|
601
|
+
deterministicSeeds: taskset.environment.deterministicSeeds,
|
|
602
|
+
lifecycle: ["create", "reset", "step", "collect", "destroy"],
|
|
603
|
+
networkPolicy: taskset.environment.networkPolicy,
|
|
604
|
+
defaultTimeoutMs: taskset.environment.defaultTimeoutMs
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function portableTools(taskset) {
|
|
608
|
+
const admitted = taskset.environment.metadata.portableTools;
|
|
609
|
+
if (admitted !== void 0) {
|
|
610
|
+
return ToolDeclarationSchema.array().max(200).parse(admitted);
|
|
611
|
+
}
|
|
612
|
+
const bindings = taskset.environment.actionBindings ?? [];
|
|
613
|
+
if (bindings.length) return bindings.map((binding) => ({
|
|
614
|
+
name: binding.modelToolName,
|
|
615
|
+
description: binding.description,
|
|
616
|
+
inputSchema: binding.inputSchema,
|
|
617
|
+
inputSchemaHash: hash(binding.actionSchemaHash),
|
|
618
|
+
sideEffect: binding.sideEffect,
|
|
619
|
+
timeoutMs: binding.timeoutMs
|
|
620
|
+
}));
|
|
621
|
+
return taskset.environment.toolNames.map((name) => ({
|
|
622
|
+
name,
|
|
623
|
+
description: `Host-provided ${name} tool.`,
|
|
624
|
+
inputSchema: {},
|
|
625
|
+
inputSchemaHash: contentHash({}),
|
|
626
|
+
sideEffect: "write",
|
|
627
|
+
timeoutMs: taskset.environment.defaultTimeoutMs
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
630
|
+
function portableGrader(grader) {
|
|
631
|
+
const base = {
|
|
632
|
+
id: grader.id,
|
|
633
|
+
version: grader.version,
|
|
634
|
+
weight: grader.weight,
|
|
635
|
+
hardGate: grader.hardGate,
|
|
636
|
+
rewardEligible: grader.rewardEligible,
|
|
637
|
+
privileged: grader.privileged
|
|
638
|
+
};
|
|
639
|
+
if (grader.kind === "model_judge") return {
|
|
640
|
+
...base,
|
|
641
|
+
kind: "model_judge",
|
|
642
|
+
rubricRef: rubricAsset(grader),
|
|
643
|
+
model: modelJudgeRef(grader),
|
|
644
|
+
temperature: grader.temperature,
|
|
645
|
+
calibrationStatus: grader.calibrationStatus
|
|
646
|
+
};
|
|
647
|
+
if (grader.kind === "custom_verifier") {
|
|
648
|
+
if (grader.metadata.portableVerifierRef === void 0) {
|
|
649
|
+
throw new Error(`Custom verifier ${grader.id} requires its immutable executable asset before publication.`);
|
|
650
|
+
}
|
|
651
|
+
const imported = PortableGraderSpecSchema.safeParse(grader.metadata.portableGrader);
|
|
652
|
+
const preserveDefault = imported.success && imported.data.kind === "custom_verifier" && imported.data.exportName === void 0 && grader.exportName === "verify";
|
|
653
|
+
return {
|
|
654
|
+
...base,
|
|
655
|
+
kind: "custom_verifier",
|
|
656
|
+
verifierRef: ImmutableAssetRefSchema.parse(grader.metadata.portableVerifierRef),
|
|
657
|
+
timeoutMs: grader.timeoutMs,
|
|
658
|
+
...preserveDefault ? {} : { exportName: grader.exportName },
|
|
659
|
+
networkPolicy: "none"
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
if (grader.kind === "human") return {
|
|
663
|
+
...base,
|
|
664
|
+
kind: "human",
|
|
665
|
+
rubricRef: rubricAsset(grader),
|
|
666
|
+
reviewerRole: grader.reviewerRole
|
|
667
|
+
};
|
|
668
|
+
return {
|
|
669
|
+
...base,
|
|
670
|
+
...portableDeterministicCheck(grader)
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function portableCapabilities(taskset) {
|
|
674
|
+
const admitted = taskset.metadata.portableCapabilities;
|
|
675
|
+
if (admitted !== void 0) {
|
|
676
|
+
return CapabilityRequirementSchema.array().max(200).parse(admitted);
|
|
677
|
+
}
|
|
678
|
+
return [
|
|
679
|
+
...taskset.capabilities.requiresTools ? [{ id: "tools", required: true, scopes: taskset.environment.toolNames }] : [],
|
|
680
|
+
...taskset.capabilities.requiresState ? [{ id: "local-state", required: true, scopes: [] }] : [],
|
|
681
|
+
...taskset.capabilities.requiresPrivilegedGrading ? [{ id: "private-verifier", required: true, scopes: taskset.policy.hiddenGraderRefs }] : [],
|
|
682
|
+
...taskset.policy.connectedAppScopes.map((scope) => ({
|
|
683
|
+
id: `connected-app-${segment(scope)}`,
|
|
684
|
+
required: true,
|
|
685
|
+
scopes: [scope]
|
|
686
|
+
}))
|
|
687
|
+
].map((requirement) => ({
|
|
688
|
+
...requirement,
|
|
689
|
+
portability: requirement.id === "local-state" ? "host_adapter" : "portable"
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
function assertReleaseBindings(input) {
|
|
693
|
+
if (input.draft.environmentRelease?.id !== input.environmentRelease.id || input.draft.environmentRelease.contentHash !== input.environmentRelease.contentHash) {
|
|
694
|
+
throw new Error("Admitted Taskset Release binds a different Environment Release.");
|
|
695
|
+
}
|
|
696
|
+
if (input.draft.verifierSetRelease?.id !== input.verifierSetRelease.id || input.draft.verifierSetRelease.contentHash !== input.verifierSetRelease.contentHash) {
|
|
697
|
+
throw new Error("Admitted Taskset Release binds a different Verifier Set Release.");
|
|
698
|
+
}
|
|
699
|
+
if (contentHash(input.draft.environment) !== contentHash(input.environmentRelease.contract)) {
|
|
700
|
+
throw new Error("Admitted Taskset Environment differs from its bound Environment Release.");
|
|
701
|
+
}
|
|
702
|
+
if (contentHash(input.draft.graders) !== contentHash(input.verifierSetRelease.graders)) {
|
|
703
|
+
throw new Error("Admitted Taskset graders differ from its bound Verifier Set Release.");
|
|
704
|
+
}
|
|
705
|
+
return input.draft;
|
|
706
|
+
}
|
|
707
|
+
function modelJudgeRef(grader) {
|
|
708
|
+
const previous = grader.metadata.portableGrader === void 0 ? null : PortableGraderSpecSchema.parse(grader.metadata.portableGrader);
|
|
709
|
+
const revision = previous?.kind === "model_judge" && previous.model?.providerId === grader.judge.providerId && previous.model.modelId === grader.judge.modelId ? previous.model.revision : null;
|
|
710
|
+
return { ...grader.judge, revision };
|
|
711
|
+
}
|
|
712
|
+
function rubricAsset(grader) {
|
|
713
|
+
const contentHash2 = sha256(grader.rubric);
|
|
714
|
+
const sizeBytes = new TextEncoder().encode(grader.rubric).byteLength;
|
|
715
|
+
const reference = grader.metadata.portableRubricRef;
|
|
716
|
+
if (reference !== void 0) {
|
|
717
|
+
const asset = ImmutableAssetRefSchema.parse(reference);
|
|
718
|
+
if (asset.contentHash !== contentHash2 || asset.sizeBytes !== sizeBytes || asset.visibility === "policy") throw new Error("Taskset rubric differs from its published private source.");
|
|
719
|
+
return asset;
|
|
720
|
+
}
|
|
721
|
+
return { id: `rubric-${grader.id}`, path: `graders/${segment(grader.id)}/rubric.md`, contentHash: contentHash2, sizeBytes, mediaType: "text/markdown", visibility: "verifier" };
|
|
722
|
+
}
|
|
723
|
+
function hash(value) {
|
|
724
|
+
return /^[a-f0-9]{64}$/.test(value) ? value : contentHash(value);
|
|
725
|
+
}
|
|
726
|
+
function segment(value) {
|
|
727
|
+
const normalized = value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
728
|
+
return normalized || "asset";
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// src/taskset-package-projection.ts
|
|
732
|
+
import { learningRef as learningRef5, taskBatchPackageMetadata as taskBatchPackageMetadata3, verifyLearningTextAsset as verifyLearningTextAsset3 } from "@openpond/evals/learning";
|
|
733
|
+
|
|
734
|
+
// src/taskset-package-grader-projection.ts
|
|
735
|
+
import { compileBoundGraders as compileBoundGraders3, resolveBoundRewards as resolveBoundRewards2 } from "@openpond/evals/rewards";
|
|
736
|
+
import { learningRef as learningRef4, verifyLearningTextAsset as verifyLearningTextAsset2 } from "@openpond/evals/learning";
|
|
737
|
+
import { z } from "zod";
|
|
738
|
+
function importedPackageGraders(value) {
|
|
739
|
+
const authoring = value.taskset.metadata.ordinaryAuthoring;
|
|
740
|
+
const calibrationFixtures = z.record(z.string(), z.array(z.string().min(1)).max(1e5)).parse(authoring?.judgeCalibrationFixtures ?? {});
|
|
741
|
+
return value.taskset.graders.map((grader) => {
|
|
742
|
+
const base = { ...grader, label: grader.id, metadata: { portableGrader: grader } };
|
|
743
|
+
if (grader.kind === "custom_verifier") return GraderSpecSchema.parse({
|
|
744
|
+
...base,
|
|
745
|
+
module: learningVerifierModule(grader.verifierRef.contentHash),
|
|
746
|
+
exportName: grader.exportName ?? "verify",
|
|
747
|
+
metadata: { ...base.metadata, portableVerifierRef: grader.verifierRef }
|
|
748
|
+
});
|
|
749
|
+
if (grader.kind === "human" || grader.kind === "model_judge") {
|
|
750
|
+
const file = value.files.find((file2) => file2.asset.id === grader.rubricRef.id);
|
|
751
|
+
if (!file) throw new Error(`Imported rubric is missing: ${grader.id}.`);
|
|
752
|
+
const rubric = new TextDecoder("utf-8", { fatal: true }).decode(decodeTasksetPackageFile(file));
|
|
753
|
+
const metadata = { ...base.metadata, portableRubricRef: grader.rubricRef };
|
|
754
|
+
if (grader.kind === "human") return GraderSpecSchema.parse({ ...base, rubric, metadata });
|
|
755
|
+
if (!grader.model) throw new Error(`Imported judge ${grader.id} requires its declared model before local preparation.`);
|
|
756
|
+
return GraderSpecSchema.parse({
|
|
757
|
+
...base,
|
|
758
|
+
rubric,
|
|
759
|
+
metadata,
|
|
760
|
+
judge: grader.model,
|
|
761
|
+
temperature: grader.temperature ?? 0,
|
|
762
|
+
calibrationStatus: "pending",
|
|
763
|
+
calibrationFixtureRefs: calibrationFixtures[grader.id] ?? []
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
return GraderSpecSchema.parse({
|
|
767
|
+
...base,
|
|
768
|
+
kind: grader.kind === "artifact" ? "file" : grader.kind,
|
|
769
|
+
config: grader.kind === "artifact" ? { ...grader.config, ...grader.config.refIncludes === void 0 ? {} : { pathIncludes: grader.config.refIncludes } } : grader.config
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
function projectLearningBatchGraders(binding, rewards, assets = []) {
|
|
774
|
+
const resolved = resolveBoundRewards2(binding, rewards);
|
|
775
|
+
return compileBoundGraders3(binding, rewards).map((grader) => {
|
|
776
|
+
const reward = resolved.find(({ source }) => source.graderId === grader.id).reward;
|
|
777
|
+
const base = { ...grader, label: reward.name, metadata: { rewardBinding: learningRef4(binding) } };
|
|
778
|
+
if (grader.kind === "model_judge") throw new Error(`Reward ${grader.id} needs a calibrated model execution adapter before preparation.`);
|
|
779
|
+
if (grader.kind === "custom_verifier") return GraderSpecSchema.parse({
|
|
780
|
+
...base,
|
|
781
|
+
module: learningVerifierModule(grader.verifierRef.contentHash),
|
|
782
|
+
exportName: grader.exportName ?? "verify",
|
|
783
|
+
metadata: { ...base.metadata, portableVerifierRef: grader.verifierRef }
|
|
784
|
+
});
|
|
785
|
+
if (grader.kind === "human") {
|
|
786
|
+
const asset = assets.find((asset2) => asset2.id === grader.rubricRef.id);
|
|
787
|
+
if (!asset) throw new Error(`Reward ${grader.id} is missing its immutable rubric.`);
|
|
788
|
+
return GraderSpecSchema.parse({ ...base, rubric: verifyLearningTextAsset2(asset, grader.rubricRef) });
|
|
789
|
+
}
|
|
790
|
+
return GraderSpecSchema.parse({ ...base, kind: grader.kind === "artifact" ? "file" : grader.kind });
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
function learningVerifierModule(hash2) {
|
|
794
|
+
return `graders/reward-${hash2}.js`;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/taskset-package-projection.ts
|
|
798
|
+
function prepareImportedTasksetPackage(input) {
|
|
799
|
+
const value = validateTasksetPackage(input.package);
|
|
800
|
+
const release = value.taskset;
|
|
801
|
+
const resources = value.modelResources;
|
|
802
|
+
const learning = value.learningResources ? taskBatchPackageMetadata3(release) : void 0;
|
|
803
|
+
const source = TasksetSourceRefSchema.parse({
|
|
804
|
+
schemaVersion: "openpond.uploadedFileDatasetSource.v1",
|
|
805
|
+
kind: "uploaded_file",
|
|
806
|
+
id: `package-source-${contentHash({ profileId: input.profileId, packageHash: value.contentHash })}`,
|
|
807
|
+
profileId: input.profileId,
|
|
808
|
+
title: input.name,
|
|
809
|
+
sourceHash: value.contentHash,
|
|
810
|
+
occurredAt: input.createdAt,
|
|
811
|
+
licensingStatus: "pending",
|
|
812
|
+
secretScanStatus: "pending",
|
|
813
|
+
piiScanStatus: "pending",
|
|
814
|
+
originalFileNames: ["taskset-package.json"],
|
|
815
|
+
mediaTypes: ["application/json"],
|
|
816
|
+
sourceFileHashes: [value.contentHash],
|
|
817
|
+
totalBytes: new TextEncoder().encode(JSON.stringify(value)).byteLength,
|
|
818
|
+
parserVersion: "openpond.tasksetPackage.v1",
|
|
819
|
+
metadata: {}
|
|
820
|
+
});
|
|
821
|
+
const draft = createTasksetDraft({ profileId: input.profileId, id: `${release.id}-import`, name: input.name, now: input.createdAt });
|
|
822
|
+
const files = [];
|
|
823
|
+
for (const grader of release.graders) if (grader.kind === "custom_verifier") {
|
|
824
|
+
const asset = resources?.assets.find((asset2) => asset2.id === grader.verifierRef.id);
|
|
825
|
+
const file = value.files.find((file2) => file2.asset.id === grader.verifierRef.id);
|
|
826
|
+
if (!file) throw new Error(`Imported verifier source is missing: ${grader.id}.`);
|
|
827
|
+
const name = learningVerifierModule(grader.verifierRef.contentHash);
|
|
828
|
+
if (!files.some((file2) => file2.path === name)) files.push({ path: name, role: "verifier", content: asset ? verifyLearningTextAsset3(asset, grader.verifierRef) : new TextDecoder("utf-8", { fatal: true }).decode(decodeTasksetPackageFile(file)) });
|
|
829
|
+
}
|
|
830
|
+
const authoring = release.metadata.ordinaryAuthoring ?? release.metadata.starterAuthoring;
|
|
831
|
+
const fixtures = GraderFixtureSchema.array().max(1e5).parse(authoring?.graderFixtures ?? []);
|
|
832
|
+
const kind = release.environment.kind === "text" ? "chat" : release.environment.kind === "custom_program" ? "program" : release.environment.kind;
|
|
833
|
+
const projected = TasksetSchema.parse({
|
|
834
|
+
schemaVersion: "openpond.taskset.v1",
|
|
835
|
+
id: release.id,
|
|
836
|
+
revision: release.revision,
|
|
837
|
+
profileId: input.profileId,
|
|
838
|
+
profileRelease: null,
|
|
839
|
+
createImproveRunId: null,
|
|
840
|
+
name: input.name,
|
|
841
|
+
objective: resolveTasksetPackageInstructions(value),
|
|
842
|
+
status: "needs_review",
|
|
843
|
+
sourceRefs: [source],
|
|
844
|
+
datasetArtifact: null,
|
|
845
|
+
policy: release.policy,
|
|
846
|
+
environment: {
|
|
847
|
+
...draft.environment,
|
|
848
|
+
kind,
|
|
849
|
+
entrypoint: release.environment.entrypoint,
|
|
850
|
+
resources: TasksetEnvironmentResourceSchema.array().max(1e4).parse(release.metadata.environmentResources ?? []),
|
|
851
|
+
stateful: release.environment.stateful,
|
|
852
|
+
deterministicSeeds: release.environment.deterministicSeeds,
|
|
853
|
+
toolNames: release.tools.map((tool) => tool.name),
|
|
854
|
+
defaultTimeoutMs: release.environment.defaultTimeoutMs,
|
|
855
|
+
networkPolicy: release.environment.networkPolicy,
|
|
856
|
+
metadata: {
|
|
857
|
+
runtimeSourceTasksetId: tasksetPackageSourceId(input.profileId, value.contentHash),
|
|
858
|
+
portableEnvironment: release.environment,
|
|
859
|
+
portableTools: release.tools,
|
|
860
|
+
portableExecutionResources: { environment: value.environment, verifierSet: value.verifierSet }
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
capabilities: {
|
|
864
|
+
...draft.capabilities,
|
|
865
|
+
taskKind: kind === "chat" ? "chat" : kind === "program" ? "custom_program" : "single_agent",
|
|
866
|
+
compatibleMethods: ["none"],
|
|
867
|
+
requiresTools: release.tools.length > 0,
|
|
868
|
+
requiresState: release.environment.stateful,
|
|
869
|
+
rewardKinds: [...new Set(release.graders.map((grader) => grader.kind === "human" ? "human" : grader.kind === "model_judge" ? "model_judge" : "deterministic"))]
|
|
870
|
+
},
|
|
871
|
+
tasks: release.tasks.map((task) => ({
|
|
872
|
+
...task,
|
|
873
|
+
schemaVersion: "openpond.taskData.v1",
|
|
874
|
+
sourceRefs: [source.id],
|
|
875
|
+
assets: task.artifactRefs.map((asset) => ({
|
|
876
|
+
id: asset.id,
|
|
877
|
+
sourceRefId: source.id,
|
|
878
|
+
artifactRef: asset.path,
|
|
879
|
+
fileName: asset.path.split("/").at(-1),
|
|
880
|
+
mediaType: asset.mediaType,
|
|
881
|
+
sha256: asset.contentHash,
|
|
882
|
+
sizeBytes: asset.sizeBytes,
|
|
883
|
+
split: task.split,
|
|
884
|
+
metadata: { portableAsset: asset }
|
|
885
|
+
})),
|
|
886
|
+
...task.requiredOutputs ? { requiredOutputs: task.requiredOutputs.map((output) => ({
|
|
887
|
+
...output,
|
|
888
|
+
schemaRef: output.schemaRef?.id ?? null,
|
|
889
|
+
maxBytes: output.maxBytes ?? void 0
|
|
890
|
+
})) } : {},
|
|
891
|
+
metadata: { portableTaskRecord: task, exampleOrigin: "imported" }
|
|
892
|
+
})),
|
|
893
|
+
graders: resources ? projectLearningBatchGraders(resources.rewardBinding, resources.rewards, resources.assets) : learning ? projectLearningBatchGraders(learning.binding, learning.rewards, value.learningResources.assets) : importedPackageGraders(value),
|
|
894
|
+
graderFixtures: fixtures,
|
|
895
|
+
learningSignals: draft.learningSignals,
|
|
896
|
+
...release.metrics ? { metrics: release.metrics } : {},
|
|
897
|
+
authoringProvenance: {
|
|
898
|
+
schemaVersion: "openpond.taskAuthoringProvenance.v1",
|
|
899
|
+
model: null,
|
|
900
|
+
modelConfig: {},
|
|
901
|
+
skillHash: contentHash("openpond-package-import-v1"),
|
|
902
|
+
promptTemplateVersion: "package-import-v1",
|
|
903
|
+
buildIntent: "discovery",
|
|
904
|
+
buildSpecification: null,
|
|
905
|
+
evidenceHashes: [value.contentHash],
|
|
906
|
+
tasksetSdkVersion: "package-import-v1",
|
|
907
|
+
sourceCommit: null,
|
|
908
|
+
repairHistory: [],
|
|
909
|
+
createdAt: input.createdAt
|
|
910
|
+
},
|
|
911
|
+
readiness: null,
|
|
912
|
+
contentHash: "00000000",
|
|
913
|
+
createdAt: input.createdAt,
|
|
914
|
+
updatedAt: input.createdAt,
|
|
915
|
+
metadata: {
|
|
916
|
+
importedPackageHash: value.contentHash,
|
|
917
|
+
...learning ? { learning } : {},
|
|
918
|
+
portableFileInventory: value.files.map((file) => ({ asset: file.asset, sourcePath: file.asset.path })),
|
|
919
|
+
...resources ? {
|
|
920
|
+
taskDefinition: learningRef5(resources.taskDefinition),
|
|
921
|
+
rewardBinding: learningRef5(resources.rewardBinding),
|
|
922
|
+
rewardExecution: { binding: resources.rewardBinding, rewards: resources.rewards }
|
|
923
|
+
} : {},
|
|
924
|
+
portableCapabilities: release.capabilities,
|
|
925
|
+
derivedPortableMetadata: release.metadata,
|
|
926
|
+
...release.metadata.modelTasksetDerivation ? { modelTasksetDerivation: release.metadata.modelTasksetDerivation } : {}
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
return { package: value, taskset: TasksetSchema.parse({ ...projected, contentHash: computeTasksetHash(projected) }), generatedFiles: files };
|
|
930
|
+
}
|
|
931
|
+
function tasksetPackageSourceId(profileId, packageHash) {
|
|
932
|
+
return `package-${contentHash({ profileId, packageHash })}`;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// src/taskset-authored-files.ts
|
|
936
|
+
import { z as z2 } from "zod";
|
|
937
|
+
|
|
938
|
+
// src/taskset-authored-tool-environment.ts
|
|
939
|
+
import { createEnvironmentRelease as createEnvironmentRelease2 } from "@openpond/evals";
|
|
940
|
+
import { JavaScriptEnvironmentDefinitionSchema } from "@openpond/evals/javascript-environment";
|
|
941
|
+
import { learningRef as learningRef6, sealLearningContent as sealLearningContent3 } from "@openpond/evals/learning";
|
|
942
|
+
function prepareAuthoredToolEnvironment(taskset, bytes, inventory, adapterId) {
|
|
943
|
+
if (taskset.environment.entrypoint !== "openpond.javascript-environment.v1") return { taskset, inventory, generatedFiles: [] };
|
|
944
|
+
const declarationPath = "environment/execution.json";
|
|
945
|
+
const declaration = bytes.get(declarationPath);
|
|
946
|
+
if (!declaration || declaration.length > 524288) throw new Error("Authored tool environment requires its bounded private execution declaration.");
|
|
947
|
+
const previous = ModelStarterExecutionSchema.parse(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(declaration)));
|
|
948
|
+
const repin = (ref) => {
|
|
949
|
+
if (!ref) return null;
|
|
950
|
+
const file2 = inventory.find((file3) => file3.asset.id === ref.id && file3.asset.path === ref.path);
|
|
951
|
+
if (!file2) throw new Error(`Authored environment dependency is missing: ${ref.id}.`);
|
|
952
|
+
return file2.asset;
|
|
953
|
+
};
|
|
954
|
+
const { contentHash: _javascriptHash, ...javascriptContent } = previous.javascript;
|
|
955
|
+
const javascript = JavaScriptEnvironmentDefinitionSchema.parse(sealLearningContent3({
|
|
956
|
+
...javascriptContent,
|
|
957
|
+
id: `javascript-${taskset.id}`,
|
|
958
|
+
revision: taskset.revision,
|
|
959
|
+
module: repin(previous.javascript.module)
|
|
960
|
+
}));
|
|
961
|
+
if (contentHash(javascript.tools) !== contentHash(taskset.environment.metadata.portableTools) || contentHash(javascript.tools.map((tool) => tool.name)) !== contentHash(taskset.environment.toolNames)) throw new Error("Authored environment tools differ from the Taskset's declared tools.");
|
|
962
|
+
const environment = createEnvironmentRelease2({
|
|
963
|
+
schemaVersion: "openpond.environmentRelease.v1",
|
|
964
|
+
id: `environment-${taskset.id}`,
|
|
965
|
+
revision: taskset.revision,
|
|
966
|
+
contract: portableTasksetEnvironment(taskset),
|
|
967
|
+
actionSchemaRef: repin(previous.environment.actionSchemaRef),
|
|
968
|
+
observationSchemaRef: repin(previous.environment.observationSchemaRef),
|
|
969
|
+
stateSchemaRef: repin(previous.environment.stateSchemaRef),
|
|
970
|
+
artifactCollection: previous.environment.artifactCollection,
|
|
971
|
+
adapterConformanceHashes: {},
|
|
972
|
+
metadata: { javascriptEnvironment: learningRef6(javascript), resources: taskset.environment.resources ?? [] }
|
|
973
|
+
});
|
|
974
|
+
const prepared = TasksetSchema.parse({ ...taskset, environment: {
|
|
975
|
+
...taskset.environment,
|
|
976
|
+
metadata: { ...taskset.environment.metadata, portableExecutionResources: { environment } }
|
|
977
|
+
} });
|
|
978
|
+
const releases = materializePortableTasksetRelease({ taskset: prepared, adapterId });
|
|
979
|
+
const file = createTasksetPackageExecutionFile({ javascript, environment, verifierSet: releases.verifierSetRelease });
|
|
980
|
+
const nextInventory = [...inventory.filter((entry) => entry.sourcePath !== declarationPath), { asset: file.asset, sourcePath: declarationPath }];
|
|
981
|
+
const finalized = TasksetSchema.parse({ ...prepared, metadata: { ...prepared.metadata, portableFileInventory: nextInventory } });
|
|
982
|
+
return {
|
|
983
|
+
taskset: TasksetSchema.parse({ ...finalized, contentHash: computeTasksetHash(finalized) }),
|
|
984
|
+
inventory: nextInventory,
|
|
985
|
+
generatedFiles: [{ path: declarationPath, role: "environment", content: new TextDecoder().decode(decodeTasksetPackageFile(file)) }]
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/taskset-authored-files.ts
|
|
990
|
+
var AuthoredTasksetFileInventorySchema = z2.array(z2.object({
|
|
991
|
+
asset: ImmutableAssetRefSchema,
|
|
992
|
+
sourcePath: z2.string().min(1)
|
|
993
|
+
}).strict()).max(1e4);
|
|
994
|
+
var GENERATED_MANIFESTS = /* @__PURE__ */ new Set(["taskset.json", "capabilities.json", "data/tasks.jsonl", "graders/graders.json", "fixtures/grader-fixtures.json", "environment/taskset.ts"]);
|
|
995
|
+
function isGeneratedTasksetPublicationFilePath(path) {
|
|
996
|
+
return GENERATED_MANIFESTS.has(path);
|
|
997
|
+
}
|
|
998
|
+
function prepareAuthoredTasksetSource(tasksetInput, sourceFiles, adapterId) {
|
|
999
|
+
const taskset = TasksetSchema.parse(tasksetInput);
|
|
1000
|
+
if (taskset.metadata.taskDefinition !== void 0 || taskset.metadata.rewardBinding !== void 0) return { taskset, generatedFiles: [] };
|
|
1001
|
+
const bytes = /* @__PURE__ */ new Map();
|
|
1002
|
+
let total = 0;
|
|
1003
|
+
for (const [name, data] of sourceFiles) {
|
|
1004
|
+
TasksetDraftFilePathSchema.parse(name);
|
|
1005
|
+
total += data.byteLength;
|
|
1006
|
+
if (bytes.size >= 1e4 || total > MAX_TASKSET_PACKAGE_BYTES * 3 / 4) throw new Error("Taskset source exceeds the package byte limit.");
|
|
1007
|
+
bytes.set(name, data.slice());
|
|
1008
|
+
}
|
|
1009
|
+
const aggregator = taskset.metrics?.customAggregator;
|
|
1010
|
+
const aggregatorBytes = aggregator ? bytes.get(aggregator.module) : void 0;
|
|
1011
|
+
if (aggregator && !aggregatorBytes) throw new Error("Declared Taskset metric module is missing.");
|
|
1012
|
+
const metrics = aggregator && aggregatorBytes ? { ...taskset.metrics, customAggregator: { ...aggregator, contentHash: sha256(aggregatorBytes) } } : taskset.metrics;
|
|
1013
|
+
const inventory = /* @__PURE__ */ new Map();
|
|
1014
|
+
const declaredPaths = /* @__PURE__ */ new Set();
|
|
1015
|
+
const generatedFiles = [];
|
|
1016
|
+
const ref = (id, sourcePath, mediaType, visibility) => {
|
|
1017
|
+
const source = bytes.get(sourcePath);
|
|
1018
|
+
if (!source) throw new Error(`Declared Taskset file is missing: ${sourcePath}.`);
|
|
1019
|
+
return { id, path: sourcePath, contentHash: sha256(source), sizeBytes: source.byteLength, mediaType, visibility };
|
|
1020
|
+
};
|
|
1021
|
+
const add = (asset, sourcePath = asset.path) => {
|
|
1022
|
+
const previous = inventory.get(asset.id);
|
|
1023
|
+
if (previous && contentHash(previous) !== contentHash({ asset, sourcePath })) throw new Error(`Conflicting Taskset file identity: ${asset.id}.`);
|
|
1024
|
+
const source = bytes.get(sourcePath);
|
|
1025
|
+
if (!source || source.length !== asset.sizeBytes || sha256(source) !== asset.contentHash) throw new Error(`Taskset file differs from its declared bytes: ${asset.id}.`);
|
|
1026
|
+
inventory.set(asset.id, { asset, sourcePath });
|
|
1027
|
+
declaredPaths.add(sourcePath);
|
|
1028
|
+
};
|
|
1029
|
+
for (const task of taskset.tasks) {
|
|
1030
|
+
const portable = projectPortableTaskRecord(task);
|
|
1031
|
+
for (const asset of portable.artifactRefs) add(asset, task.assets?.find((candidate) => candidate.id === asset.id)?.artifactRef ?? asset.path);
|
|
1032
|
+
for (const output of portable.requiredOutputs ?? []) if (output.schemaRef) add(output.schemaRef);
|
|
1033
|
+
}
|
|
1034
|
+
for (const resource of taskset.environment.resources ?? []) add(ref(resource.id, resource.path, resource.mediaType ?? "application/octet-stream", resource.visibility === "policy_visible" ? "policy" : "host_private"));
|
|
1035
|
+
const graders = taskset.graders.map((grader) => {
|
|
1036
|
+
if (grader.kind === "custom_verifier") {
|
|
1037
|
+
let asset = ref(`verifier-${grader.id}`, grader.module, "application/javascript", "host_private");
|
|
1038
|
+
const previous = ImmutableAssetRefSchema.safeParse(grader.metadata.portableVerifierRef);
|
|
1039
|
+
if (previous.success && previous.data.contentHash === asset.contentHash && previous.data.sizeBytes === asset.sizeBytes) asset = previous.data;
|
|
1040
|
+
add(asset, grader.module);
|
|
1041
|
+
return { ...grader, metadata: { ...grader.metadata, portableVerifierRef: asset } };
|
|
1042
|
+
}
|
|
1043
|
+
if (grader.kind === "human" || grader.kind === "model_judge") {
|
|
1044
|
+
const content = new TextEncoder().encode(grader.rubric);
|
|
1045
|
+
const sourcePath = `graders/rubric-${sha256(content)}.md`;
|
|
1046
|
+
bytes.set(sourcePath, content);
|
|
1047
|
+
const asset = ref(`rubric-${grader.id}`, sourcePath, "text/markdown", "verifier");
|
|
1048
|
+
add(asset);
|
|
1049
|
+
generatedFiles.push({ path: sourcePath, role: "verifier", content: grader.rubric });
|
|
1050
|
+
return { ...grader, metadata: { ...grader.metadata, portableRubricRef: asset } };
|
|
1051
|
+
}
|
|
1052
|
+
return grader;
|
|
1053
|
+
});
|
|
1054
|
+
if (aggregator && ![...inventory.values()].some((file) => file.asset.path === aggregator.module && file.sourcePath === aggregator.module && file.asset.visibility !== "policy")) {
|
|
1055
|
+
add(ref(`metric-${contentHash(aggregator.module)}`, aggregator.module, "application/javascript", "host_private"));
|
|
1056
|
+
}
|
|
1057
|
+
const previousInventory = AuthoredTasksetFileInventorySchema.parse(taskset.metadata.portableFileInventory ?? []);
|
|
1058
|
+
for (const name of [...bytes.keys()].sort()) if (!declaredPaths.has(name)) {
|
|
1059
|
+
const previous = previousInventory.find((file) => file.sourcePath === name && !inventory.has(file.asset.id));
|
|
1060
|
+
add(previous ? { ...ref(previous.asset.id, name, previous.asset.mediaType, previous.asset.visibility), path: previous.asset.path } : ref(`taskset-file-${contentHash(name)}`, name, "application/octet-stream", "host_private"), name);
|
|
1061
|
+
}
|
|
1062
|
+
const { importedPackageHash, derivedPortableMetadata: _derived, ...metadata } = taskset.metadata;
|
|
1063
|
+
const environmentMetadata = { ...taskset.environment.metadata };
|
|
1064
|
+
if (environmentMetadata.portableExecutionResources !== void 0) {
|
|
1065
|
+
const resources = z2.object({ environment: z2.unknown(), verifierSet: z2.unknown().optional() }).parse(environmentMetadata.portableExecutionResources);
|
|
1066
|
+
environmentMetadata.portableExecutionResources = { environment: resources.environment };
|
|
1067
|
+
}
|
|
1068
|
+
const prepared = TasksetSchema.parse({
|
|
1069
|
+
...taskset,
|
|
1070
|
+
graders,
|
|
1071
|
+
metrics,
|
|
1072
|
+
environment: { ...taskset.environment, metadata: environmentMetadata },
|
|
1073
|
+
metadata: { ...metadata, ...importedPackageHash === void 0 ? {} : { sourceImportedPackageHash: importedPackageHash }, portableFileInventory: AuthoredTasksetFileInventorySchema.parse([...inventory.values()].sort((left, right) => left.asset.id.localeCompare(right.asset.id))) }
|
|
1074
|
+
});
|
|
1075
|
+
const executable = prepareAuthoredToolEnvironment(prepared, bytes, [...inventory.values()], adapterId);
|
|
1076
|
+
return { taskset: TasksetSchema.parse({ ...executable.taskset, contentHash: computeTasksetHash(executable.taskset) }), generatedFiles: [...generatedFiles, ...executable.generatedFiles] };
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// src/taskset-draft-package-compiler.ts
|
|
1080
|
+
function compileModelTasksetDraftWorkspace(input) {
|
|
1081
|
+
const workspace = validateTasksetDraftWorkspace(input.workspace);
|
|
1082
|
+
const preparation = ModelTasksetDraftPreparationSchema.parse(input.preparation);
|
|
1083
|
+
if (workspace.draft.id !== preparation.draftId || workspace.draft.modelScope?.modelId !== preparation.lineage.owner.modelId || contentHash(workspace.draft.modelScope?.source ?? null) !== contentHash(preparation)) throw new Error("Taskset draft differs from its retained source preparation.");
|
|
1084
|
+
const taskset = publishTasksetDraft({ draft: workspace.draft, now: input.now, sourcePackageHash: workspace.contentHash });
|
|
1085
|
+
const files = new Map(workspace.files.map((file) => [file.path, decodeTasksetDraftWorkspaceFile(file)]));
|
|
1086
|
+
for (const [path, source] of renderTasksetDraftManifests(workspace.draft)) if (!isGeneratedTasksetPublicationFilePath(path)) files.set(path, new TextEncoder().encode(source));
|
|
1087
|
+
const authored = prepareAuthoredTasksetSource(taskset, files, input.adapterId);
|
|
1088
|
+
for (const file of authored.generatedFiles) files.set(file.path, new TextEncoder().encode(file.content));
|
|
1089
|
+
const releases = materializePortableTasksetRelease({ taskset: authored.taskset, adapterId: input.adapterId });
|
|
1090
|
+
const inventory = AuthoredTasksetFileInventorySchema.parse(authored.taskset.metadata.portableFileInventory);
|
|
1091
|
+
const edited = createTasksetPackage({
|
|
1092
|
+
schemaVersion: "openpond.tasksetPackage.v1",
|
|
1093
|
+
taskset: releases.tasksetRelease,
|
|
1094
|
+
environment: releases.environmentRelease,
|
|
1095
|
+
verifierSet: releases.verifierSetRelease,
|
|
1096
|
+
files: inventory.map((entry) => {
|
|
1097
|
+
const bytes = files.get(entry.sourcePath);
|
|
1098
|
+
if (!bytes) throw new Error(`Captured Taskset file is missing: ${entry.sourcePath}.`);
|
|
1099
|
+
return { asset: entry.asset, base64: Buffer.from(bytes).toString("base64") };
|
|
1100
|
+
})
|
|
1101
|
+
});
|
|
1102
|
+
return publishModelTasksetDraftPackage({ preparation, edited });
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// src/taskset-draft-source.ts
|
|
1106
|
+
import { z as z3 } from "zod";
|
|
1107
|
+
import { learningRef as learningRef7, sameLearningRef as sameLearningRef4 } from "@openpond/evals/learning";
|
|
1108
|
+
var TasksetDraftSourceInitializationSchema = z3.object({
|
|
1109
|
+
draft: TasksetDraftSchema,
|
|
1110
|
+
filePaths: z3.array(z3.object({ assetId: z3.string().min(1), paths: z3.array(TasksetDraftFilePathSchema).min(1).max(1e4) }).strict()).max(1e4)
|
|
1111
|
+
}).strict();
|
|
1112
|
+
function prepareTasksetDraftSource(input) {
|
|
1113
|
+
const source = validateTasksetPackage(input.source);
|
|
1114
|
+
const original = TasksetDraftSchema.parse(input.sourceDraft);
|
|
1115
|
+
const preparation = ModelTasksetDraftPreparationSchema.parse(input.preparation);
|
|
1116
|
+
if (source.contentHash !== preparation.sourcePackageHash || !sameLearningRef4(learningRef7(source.taskset), preparation.sourceTasksetRef)) throw new Error("Taskset draft preparation differs from its source package.");
|
|
1117
|
+
if (source.modelResources || source.learningResources) throw new Error("This Taskset requires its bound or reviewed authoring workflow.");
|
|
1118
|
+
const inventory = AuthoredTasksetFileInventorySchema.parse(original.metadata.portableFileInventory ?? []);
|
|
1119
|
+
const sourcePath = (relative) => isManagedTasksetDraftFilePath(relative) ? `source-artifacts/${source.contentHash}/${contentHash(relative)}/${relative.split("/").at(-1)}` : relative;
|
|
1120
|
+
const references = [
|
|
1121
|
+
...original.tasks.flatMap((task) => (task.assets ?? []).map((asset) => asset.artifactRef)),
|
|
1122
|
+
...(original.environment.resources ?? []).map((resource) => resource.path),
|
|
1123
|
+
...source.taskset.tasks.flatMap((task) => (task.requiredOutputs ?? []).flatMap((output) => output.schemaRef ? [output.schemaRef.path] : [])),
|
|
1124
|
+
...original.metrics.customAggregator ? [original.metrics.customAggregator.module] : [],
|
|
1125
|
+
...original.graders.flatMap((grader) => grader.kind === "custom_verifier" ? [grader.module] : [])
|
|
1126
|
+
];
|
|
1127
|
+
if (references.some(isManagedTasksetDraftFilePath)) throw new Error("A referenced source asset occupies a reserved Taskset authoring path.");
|
|
1128
|
+
const filePaths = source.files.map((file) => {
|
|
1129
|
+
const paths = /* @__PURE__ */ new Set([file.asset.path]);
|
|
1130
|
+
for (const entry of inventory) if (entry.asset.id === file.asset.id) paths.add(entry.sourcePath);
|
|
1131
|
+
for (const task of original.tasks) for (const asset of task.assets ?? []) if (asset.id === file.asset.id) paths.add(asset.artifactRef);
|
|
1132
|
+
for (const grader of source.taskset.graders) if (grader.kind === "custom_verifier" && grader.verifierRef.id === file.asset.id) {
|
|
1133
|
+
const projected = original.graders.find((candidate) => candidate.id === grader.id);
|
|
1134
|
+
if (projected?.kind === "custom_verifier") paths.add(projected.module);
|
|
1135
|
+
}
|
|
1136
|
+
return { assetId: file.asset.id, paths: [...paths].map(sourcePath) };
|
|
1137
|
+
});
|
|
1138
|
+
const draft = TasksetDraftSchema.parse({
|
|
1139
|
+
...original,
|
|
1140
|
+
id: preparation.draftId,
|
|
1141
|
+
revision: 1,
|
|
1142
|
+
status: "draft",
|
|
1143
|
+
environment: { ...original.environment, metadata: { ...original.environment.metadata, portableExecutionResources: { environment: source.environment } } },
|
|
1144
|
+
modelScope: { modelId: preparation.lineage.owner.modelId, expectedModelRevision: input.expectedModelRevision, source: preparation },
|
|
1145
|
+
publishedTasksetRef: preparation.tasksetRevision > 1 ? preparation.sourceTasksetRef : null,
|
|
1146
|
+
metadata: {
|
|
1147
|
+
...original.metadata,
|
|
1148
|
+
modelTasksetAuthoring: preparation.lineage,
|
|
1149
|
+
portableFileInventory: inventory.map((entry) => ({ ...entry, sourcePath: sourcePath(entry.sourcePath), asset: {
|
|
1150
|
+
...entry.asset,
|
|
1151
|
+
id: isManagedTasksetDraftFilePath(entry.sourcePath) ? `source-artifact-${contentHash({ packageHash: source.contentHash, assetId: entry.asset.id })}` : entry.asset.id,
|
|
1152
|
+
path: sourcePath(entry.asset.path)
|
|
1153
|
+
} }))
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
return TasksetDraftSourceInitializationSchema.parse({ draft, filePaths });
|
|
1157
|
+
}
|
|
1158
|
+
function materializeTasksetDraftWorkspace(input) {
|
|
1159
|
+
const initialized = TasksetDraftSourceInitializationSchema.parse(input.initialized);
|
|
1160
|
+
const source = validateTasksetPackage(input.source);
|
|
1161
|
+
if (initialized.draft.modelScope?.source?.sourcePackageHash !== source.contentHash) throw new Error("Taskset draft lost its source preparation.");
|
|
1162
|
+
const files = /* @__PURE__ */ new Map();
|
|
1163
|
+
for (const mapping of initialized.filePaths) {
|
|
1164
|
+
const file = source.files.find((candidate) => candidate.asset.id === mapping.assetId);
|
|
1165
|
+
if (!file) throw new Error("Taskset draft source asset is missing.");
|
|
1166
|
+
for (const path of mapping.paths) {
|
|
1167
|
+
const previous = files.get(path);
|
|
1168
|
+
if (previous && previous.contentHash !== file.asset.contentHash) throw new Error("Taskset draft source paths conflict.");
|
|
1169
|
+
files.set(path, { path, contentHash: file.asset.contentHash, sizeBytes: file.asset.sizeBytes, base64: file.base64 });
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
for (const configured of configuredTasksetDraftFiles(initialized.draft)) if (!files.has(configured.relativePath)) {
|
|
1173
|
+
const bytes = new TextEncoder().encode(configured.source);
|
|
1174
|
+
files.set(configured.relativePath, { path: configured.relativePath, contentHash: sha256(bytes), sizeBytes: bytes.byteLength, base64: Buffer.from(bytes).toString("base64") });
|
|
1175
|
+
}
|
|
1176
|
+
let draft = initialized.draft;
|
|
1177
|
+
if (draft.metrics.customAggregator) {
|
|
1178
|
+
const file = files.get(draft.metrics.customAggregator.module);
|
|
1179
|
+
if (!file) throw new Error("Declared Taskset metric module is missing.");
|
|
1180
|
+
decodeTasksetDraftWorkspaceFile(file);
|
|
1181
|
+
draft = TasksetDraftSchema.parse({ ...draft, metrics: { ...draft.metrics, customAggregator: { ...draft.metrics.customAggregator, contentHash: file.contentHash } } });
|
|
1182
|
+
}
|
|
1183
|
+
return createTasksetDraftWorkspace({ schemaVersion: "openpond.tasksetDraftWorkspace.v1", draft, files: [...files.values()] });
|
|
1184
|
+
}
|
|
3345
1185
|
export {
|
|
1186
|
+
AuthoredTasksetFileInventorySchema,
|
|
3346
1187
|
MAX_TASKSET_PACKAGE_BYTES,
|
|
3347
1188
|
LearningDomainError3 as ModelBatchReviewError,
|
|
3348
1189
|
ModelBatchReviewInspectionSchema,
|
|
@@ -3359,6 +1200,7 @@ export {
|
|
|
3359
1200
|
TasksetDraftFileMutationSchema,
|
|
3360
1201
|
TasksetDraftFilePathSchema,
|
|
3361
1202
|
TasksetDraftFileSchema,
|
|
1203
|
+
TasksetDraftSourceInitializationSchema,
|
|
3362
1204
|
TasksetPackageContentSchema,
|
|
3363
1205
|
TasksetPackageFileSchema,
|
|
3364
1206
|
TasksetPackageLearningResourcesSchema,
|
|
@@ -3368,17 +1210,32 @@ export {
|
|
|
3368
1210
|
TasksetPackageReceiptSchema,
|
|
3369
1211
|
TasksetPackageSchema,
|
|
3370
1212
|
beginModelBatchReview,
|
|
1213
|
+
compileModelTasksetDraftWorkspace,
|
|
3371
1214
|
createTasksetPackage,
|
|
3372
1215
|
createTasksetPackageExecutionFile,
|
|
3373
1216
|
decodeTasksetPackageFile,
|
|
3374
1217
|
findModelBatchReview,
|
|
3375
1218
|
inspectModelBatchPackage,
|
|
1219
|
+
isGeneratedTasksetPublicationFilePath,
|
|
3376
1220
|
learningPackageContextFiles,
|
|
1221
|
+
learningVerifierModule,
|
|
1222
|
+
materializePortableTasksetRelease,
|
|
1223
|
+
materializeTasksetDraftWorkspace,
|
|
1224
|
+
portableTasksetEnvironment,
|
|
1225
|
+
portableTasksetTools,
|
|
1226
|
+
prepareAuthoredTasksetSource,
|
|
1227
|
+
prepareImportedTasksetPackage,
|
|
3377
1228
|
prepareModelTasksetDraft,
|
|
1229
|
+
prepareTasksetDraftSource,
|
|
1230
|
+
projectLearningBatchGraders,
|
|
1231
|
+
projectPortableTaskRecord,
|
|
1232
|
+
projectPreferenceComparisonRelease,
|
|
3378
1233
|
publishModelTasksetDraftPackage,
|
|
1234
|
+
resolvePortableTasksetRewardExecution,
|
|
3379
1235
|
resolveTasksetPackageExecution,
|
|
3380
1236
|
resolveTasksetPackageInstructions,
|
|
3381
1237
|
tasksetPackageRewardBinding,
|
|
1238
|
+
tasksetPackageSourceId,
|
|
3382
1239
|
validateTasksetLearningResources,
|
|
3383
1240
|
validateTasksetPackage
|
|
3384
1241
|
};
|