openpond-sdk 0.2.1 → 0.2.2
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 +28 -0
- package/dist/taskset-packages.js +2424 -0
- package/dist/taskset-packages.js.map +7 -0
- package/dist/types/packages/sdk/src/taskset-package-client.d.ts +1999 -0
- package/dist/types/packages/sdk/src/taskset-package-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-contracts.d.ts +1954 -0
- package/dist/types/packages/sdk/src/taskset-package-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts +3 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,2424 @@
|
|
|
1
|
+
// src/taskset-package-contracts.ts
|
|
2
|
+
import { z as z15 } 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
|
+
var IdSchema = z11.string().trim().min(1).max(500);
|
|
1863
|
+
var HashSchema = z11.string().regex(/^[a-f0-9]{64}$/);
|
|
1864
|
+
var TimestampSchema = z11.string().datetime({ offset: true });
|
|
1865
|
+
var ModelProjectImmutableRefSchema = z11.object({
|
|
1866
|
+
id: IdSchema,
|
|
1867
|
+
contentHash: HashSchema
|
|
1868
|
+
}).strict();
|
|
1869
|
+
var ModelProjectVersionedRefSchema = ModelProjectImmutableRefSchema.extend({
|
|
1870
|
+
revision: z11.number().int().positive()
|
|
1871
|
+
}).strict();
|
|
1872
|
+
var ModelProjectBaseModelSchema = z11.object({
|
|
1873
|
+
schemaVersion: z11.literal("openpond.baseModelPreference.v1"),
|
|
1874
|
+
modelId: IdSchema,
|
|
1875
|
+
revision: z11.string().trim().min(1).max(256).nullable(),
|
|
1876
|
+
tokenizerRevision: z11.string().trim().min(1).max(256).nullable(),
|
|
1877
|
+
chatTemplateHash: z11.string().trim().min(8).max(256).nullable(),
|
|
1878
|
+
modelAssetId: IdSchema.nullable(),
|
|
1879
|
+
source: z11.enum(["managed", "local", "builtin"])
|
|
1880
|
+
}).strict();
|
|
1881
|
+
var ModelProjectTrainingMethodSchema = z11.enum([
|
|
1882
|
+
"sft",
|
|
1883
|
+
"dpo",
|
|
1884
|
+
"grpo",
|
|
1885
|
+
"ppo",
|
|
1886
|
+
"sdft",
|
|
1887
|
+
"opd",
|
|
1888
|
+
"opsd",
|
|
1889
|
+
"sdpo"
|
|
1890
|
+
]);
|
|
1891
|
+
var ModelProjectRecipeDocumentSchema = z11.object({
|
|
1892
|
+
schemaVersion: z11.string().regex(/^openpond\.[A-Za-z0-9]+Recipe\.v\d+$/),
|
|
1893
|
+
method: ModelProjectTrainingMethodSchema,
|
|
1894
|
+
parameterization: z11.enum(["lora", "full"])
|
|
1895
|
+
}).catchall(z11.unknown());
|
|
1896
|
+
var ModelProjectTrainingSetupSchema = z11.object({
|
|
1897
|
+
tasksetRef: ModelProjectVersionedRefSchema.nullable().default(null),
|
|
1898
|
+
rewardBindingRef: ModelProjectVersionedRefSchema.nullable().optional(),
|
|
1899
|
+
tasksetRelease: ModelProjectImmutableRefSchema.nullable().default(null),
|
|
1900
|
+
harnessRelease: ModelProjectImmutableRefSchema.nullable().default(null),
|
|
1901
|
+
baseModel: ModelProjectBaseModelSchema.nullable().default(null),
|
|
1902
|
+
method: ModelProjectTrainingMethodSchema.nullable().default(null),
|
|
1903
|
+
destinationId: IdSchema.nullable().default(null),
|
|
1904
|
+
managedRolloutPlacement: z11.enum(["local", "remote"]).default("remote"),
|
|
1905
|
+
managedGpuPlacementObjective: z11.enum(["fast", "balanced", "economical"]).default("balanced"),
|
|
1906
|
+
managedGpuRequirement: z11.enum(["any", "h100_hbm3"]).default("any"),
|
|
1907
|
+
runPreset: z11.enum(["small", "standard", "custom", "small_experiment"]).nullable().default(null),
|
|
1908
|
+
recipe: ModelProjectRecipeDocumentSchema.nullable().default(null),
|
|
1909
|
+
preferredMaximumSpendUsd: z11.number().nonnegative().nullable().default(null),
|
|
1910
|
+
preferredRetentionDays: z11.number().int().nonnegative().nullable().default(null)
|
|
1911
|
+
}).strict();
|
|
1912
|
+
var HostedModelProjectTrainingSetupSchema = ModelProjectTrainingSetupSchema.omit({ managedGpuRequirement: true });
|
|
1913
|
+
var HostedModelProjectLinkSchema = z11.object({
|
|
1914
|
+
schemaVersion: z11.literal("openpond.hostedModelProjectLink.v1"),
|
|
1915
|
+
teamId: IdSchema,
|
|
1916
|
+
projectId: IdSchema,
|
|
1917
|
+
portableProjectId: IdSchema,
|
|
1918
|
+
revision: z11.number().int().positive(),
|
|
1919
|
+
etag: HashSchema,
|
|
1920
|
+
syncedSourceRevision: z11.number().int().positive(),
|
|
1921
|
+
syncedAt: TimestampSchema,
|
|
1922
|
+
tasksets: z11.array(
|
|
1923
|
+
z11.object({
|
|
1924
|
+
localTasksetId: IdSchema,
|
|
1925
|
+
releaseId: IdSchema,
|
|
1926
|
+
releaseRevision: z11.number().int().positive(),
|
|
1927
|
+
releaseHash: HashSchema,
|
|
1928
|
+
hostedTasksetId: IdSchema,
|
|
1929
|
+
syncedAt: TimestampSchema
|
|
1930
|
+
}).strict()
|
|
1931
|
+
).max(1e4).default([])
|
|
1932
|
+
}).strict();
|
|
1933
|
+
var ModelProjectTasksetSyncSchema = z11.object({
|
|
1934
|
+
localTasksetId: IdSchema,
|
|
1935
|
+
releaseId: IdSchema,
|
|
1936
|
+
releaseRevision: z11.number().int().positive(),
|
|
1937
|
+
releaseHash: HashSchema,
|
|
1938
|
+
state: z11.enum(["syncing", "synced", "sync_failed"]),
|
|
1939
|
+
hostedTasksetId: IdSchema.nullable().default(null),
|
|
1940
|
+
lastAttemptAt: TimestampSchema,
|
|
1941
|
+
syncedAt: TimestampSchema.nullable().default(null),
|
|
1942
|
+
lastError: z11.string().trim().min(1).max(5e3).nullable().default(null)
|
|
1943
|
+
}).strict();
|
|
1944
|
+
var ModelProjectSchema = z11.object({
|
|
1945
|
+
schemaVersion: z11.literal("openpond.modelProject.v2"),
|
|
1946
|
+
id: IdSchema,
|
|
1947
|
+
profileId: IdSchema,
|
|
1948
|
+
revision: z11.number().int().positive().default(1),
|
|
1949
|
+
name: z11.string().trim().min(1).max(200),
|
|
1950
|
+
objective: z11.string().trim().max(5e3).nullable(),
|
|
1951
|
+
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
1952
|
+
defaultDestinationId: IdSchema.nullable(),
|
|
1953
|
+
trainingSetup: ModelProjectTrainingSetupSchema,
|
|
1954
|
+
hosted: HostedModelProjectLinkSchema.nullable().default(null),
|
|
1955
|
+
tasksetSyncs: z11.array(ModelProjectTasksetSyncSchema).max(1e4).default([]),
|
|
1956
|
+
createdAt: TimestampSchema,
|
|
1957
|
+
updatedAt: TimestampSchema
|
|
1958
|
+
}).strict();
|
|
1959
|
+
var ModelProjectEditableSchema = ModelProjectSchema.pick({
|
|
1960
|
+
id: true,
|
|
1961
|
+
profileId: true,
|
|
1962
|
+
name: true,
|
|
1963
|
+
objective: true,
|
|
1964
|
+
defaultBaseModel: true,
|
|
1965
|
+
defaultDestinationId: true,
|
|
1966
|
+
trainingSetup: true
|
|
1967
|
+
});
|
|
1968
|
+
var ModelProjectSaveRequestSchema = z11.object({
|
|
1969
|
+
schemaVersion: z11.literal("openpond.modelProjectSave.v1"),
|
|
1970
|
+
operationId: IdSchema,
|
|
1971
|
+
expectedRevision: z11.number().int().nonnegative(),
|
|
1972
|
+
project: ModelProjectEditableSchema
|
|
1973
|
+
}).strict();
|
|
1974
|
+
var ModelProjectConfigurationCheckSchema = z11.object({
|
|
1975
|
+
schemaVersion: z11.literal("openpond.modelProjectConfigurationCheck.v1"),
|
|
1976
|
+
configurationHash: HashSchema,
|
|
1977
|
+
projectId: IdSchema,
|
|
1978
|
+
expectedRevision: z11.number().int().nonnegative(),
|
|
1979
|
+
checkedAt: TimestampSchema,
|
|
1980
|
+
canSave: z11.boolean(),
|
|
1981
|
+
deferred: z11.array(z11.enum(["base_model", "taskset"])).max(2),
|
|
1982
|
+
findings: z11.array(z11.object({
|
|
1983
|
+
code: IdSchema,
|
|
1984
|
+
severity: z11.enum(["error", "warning"]),
|
|
1985
|
+
message: z11.string().min(1).max(5e3),
|
|
1986
|
+
field: z11.string().min(1).max(500).nullable()
|
|
1987
|
+
}).strict()).max(100)
|
|
1988
|
+
}).strict();
|
|
1989
|
+
var ModelProjectBaseModelCandidateSchema = z11.object({
|
|
1990
|
+
id: IdSchema,
|
|
1991
|
+
name: z11.string().min(1).max(500),
|
|
1992
|
+
available: z11.boolean(),
|
|
1993
|
+
preference: ModelProjectBaseModelSchema
|
|
1994
|
+
}).strict();
|
|
1995
|
+
var HostedModelProjectSyncSchema = z11.object({
|
|
1996
|
+
schemaVersion: z11.literal("openpond.hostedModelProjectSync.v2"),
|
|
1997
|
+
portableProjectId: IdSchema,
|
|
1998
|
+
name: z11.string().trim().min(1).max(200),
|
|
1999
|
+
objective: z11.string().trim().max(5e3).nullable(),
|
|
2000
|
+
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
2001
|
+
defaultDestinationId: IdSchema.nullable(),
|
|
2002
|
+
trainingSetup: HostedModelProjectTrainingSetupSchema,
|
|
2003
|
+
sourceRevision: z11.number().int().positive(),
|
|
2004
|
+
sourceUpdatedAt: TimestampSchema,
|
|
2005
|
+
expectedEtag: HashSchema.nullable().default(null)
|
|
2006
|
+
}).strict();
|
|
2007
|
+
var HostedModelProjectSummarySchema = z11.object({
|
|
2008
|
+
id: IdSchema,
|
|
2009
|
+
teamId: IdSchema,
|
|
2010
|
+
portableProjectId: IdSchema,
|
|
2011
|
+
name: z11.string().trim().min(1).max(200),
|
|
2012
|
+
objective: z11.string().trim().max(5e3).nullable(),
|
|
2013
|
+
defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
|
|
2014
|
+
defaultDestinationId: IdSchema.nullable(),
|
|
2015
|
+
trainingSetup: HostedModelProjectTrainingSetupSchema,
|
|
2016
|
+
sourceRevision: z11.number().int().positive(),
|
|
2017
|
+
sourceUpdatedAt: TimestampSchema,
|
|
2018
|
+
revision: z11.number().int().positive(),
|
|
2019
|
+
etag: HashSchema,
|
|
2020
|
+
createdAt: TimestampSchema,
|
|
2021
|
+
updatedAt: TimestampSchema
|
|
2022
|
+
}).strict();
|
|
2023
|
+
var ModelProjectResourceSummarySchema = z11.object({
|
|
2024
|
+
kind: z11.enum([
|
|
2025
|
+
"taskset_release",
|
|
2026
|
+
"harness_release",
|
|
2027
|
+
"dataset_release",
|
|
2028
|
+
"evidence_set",
|
|
2029
|
+
"model_version",
|
|
2030
|
+
"reward_model_version",
|
|
2031
|
+
"evaluation_receipt"
|
|
2032
|
+
]),
|
|
2033
|
+
ref: ModelProjectImmutableRefSchema,
|
|
2034
|
+
role: z11.string().trim().min(1).max(200).nullable().default(null),
|
|
2035
|
+
updatedAt: TimestampSchema
|
|
2036
|
+
}).strict();
|
|
2037
|
+
var HostedModelProjectDetailSchema = z11.object({
|
|
2038
|
+
project: HostedModelProjectSummarySchema,
|
|
2039
|
+
resources: z11.array(ModelProjectResourceSummarySchema).max(1e4),
|
|
2040
|
+
jobCount: z11.number().int().nonnegative(),
|
|
2041
|
+
latestJobIds: z11.array(IdSchema).max(100)
|
|
2042
|
+
}).strict();
|
|
2043
|
+
var ModelProjectApiErrorSchema = z11.object({
|
|
2044
|
+
schemaVersion: z11.literal("openpond.modelProjectApiError.v2"),
|
|
2045
|
+
code: z11.string().trim().min(1).max(200),
|
|
2046
|
+
message: z11.string().trim().min(1).max(5e3),
|
|
2047
|
+
retryable: z11.boolean().default(false),
|
|
2048
|
+
requestId: z11.string().trim().min(1).max(500).nullable().default(null),
|
|
2049
|
+
details: z11.record(z11.string(), z11.unknown()).default({})
|
|
2050
|
+
}).strict();
|
|
2051
|
+
|
|
2052
|
+
// src/model-starter-execution.ts
|
|
2053
|
+
import { z as z12 } from "zod";
|
|
2054
|
+
import { EnvironmentReleaseSchema, VerifierSetReleaseSchema } from "@openpond/evals";
|
|
2055
|
+
import { JavaScriptEnvironmentDefinitionSchema, assertJavaScriptEnvironmentDefinition } from "@openpond/evals/javascript-environment";
|
|
2056
|
+
import { createLearningTextAsset, learningRef, sealLearningContent, verifyLearningTextAsset } from "@openpond/evals/learning";
|
|
2057
|
+
import { assertBoundedTaskJson as assertBoundedTaskJson2 } from "@openpond/evals/task-schema";
|
|
2058
|
+
var HashSchema2 = z12.string().regex(/^[a-f0-9]{64}$/);
|
|
2059
|
+
var ModelStarterEnvironmentAttemptSchema = z12.object({
|
|
2060
|
+
schemaVersion: z12.literal("openpond.javascriptEnvironmentAttempt.v1"),
|
|
2061
|
+
taskId: z12.string(),
|
|
2062
|
+
status: z12.enum(["completed", "budget_exhausted", "cancelled", "timed_out", "policy_failure", "environment_failure"]),
|
|
2063
|
+
output: z12.string().nullable(),
|
|
2064
|
+
collected: z12.boolean(),
|
|
2065
|
+
environmentCleanupComplete: z12.boolean(),
|
|
2066
|
+
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(),
|
|
2067
|
+
messages: z12.array(z12.unknown()),
|
|
2068
|
+
error: z12.string().nullable(),
|
|
2069
|
+
contentHash: HashSchema2
|
|
2070
|
+
}).strict();
|
|
2071
|
+
var ModelStarterExecutionSchema = z12.object({
|
|
2072
|
+
environment: EnvironmentReleaseSchema,
|
|
2073
|
+
verifierSet: VerifierSetReleaseSchema,
|
|
2074
|
+
javascript: JavaScriptEnvironmentDefinitionSchema
|
|
2075
|
+
}).strict();
|
|
2076
|
+
var ModelStarterToolFixtureScriptSchema = z12.object({
|
|
2077
|
+
actions: z12.array(z12.object({ name: z12.string().min(1).max(64), arguments: z12.record(z12.string(), z12.unknown()) }).strict()).max(1e3)
|
|
2078
|
+
}).strict();
|
|
2079
|
+
function equal(left, right) {
|
|
2080
|
+
return sealLearningContent({ value: left }).contentHash === sealLearningContent({ value: right }).contentHash;
|
|
2081
|
+
}
|
|
2082
|
+
function assertExecutionIntegrity(execution) {
|
|
2083
|
+
assertJavaScriptEnvironmentDefinition(execution.javascript);
|
|
2084
|
+
for (const resource of [execution.environment, execution.verifierSet]) {
|
|
2085
|
+
const { contentHash: contentHash2, ...content } = resource;
|
|
2086
|
+
if (sealLearningContent(content).contentHash !== contentHash2) throw new Error(`Starter execution resource integrity failed: ${resource.id}.`);
|
|
2087
|
+
}
|
|
2088
|
+
if (!equal(execution.environment.metadata.javascriptEnvironment, learningRef(execution.javascript))) throw new Error("Starter execution resources differ from its declared task context.");
|
|
2089
|
+
}
|
|
2090
|
+
function validateModelStarterExecution(execution, taskset, assets) {
|
|
2091
|
+
if (!execution) {
|
|
2092
|
+
if (taskset.environment.entrypoint === "openpond.javascript-environment.v1") throw new Error("Starter JavaScript execution resources are missing.");
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
const { environment, verifierSet, javascript } = execution;
|
|
2096
|
+
assertExecutionIntegrity(execution);
|
|
2097
|
+
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))) {
|
|
2098
|
+
throw new Error("Starter execution resources differ from its declared task context.");
|
|
2099
|
+
}
|
|
2100
|
+
const contract = environment.contract;
|
|
2101
|
+
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) {
|
|
2102
|
+
throw new Error("Starter JavaScript environment declares unsupported host capabilities.");
|
|
2103
|
+
}
|
|
2104
|
+
for (const reference of [javascript.module, environment.actionSchemaRef, environment.observationSchemaRef, environment.stateSchemaRef]) {
|
|
2105
|
+
if (!reference) continue;
|
|
2106
|
+
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2107
|
+
if (!asset) throw new Error(`Starter environment asset is missing: ${reference.id}.`);
|
|
2108
|
+
verifyLearningTextAsset(asset, reference);
|
|
2109
|
+
}
|
|
2110
|
+
for (const task of taskset.tasks) {
|
|
2111
|
+
const asset = assets.find((asset2) => asset2.id === task.privilegedContextRef);
|
|
2112
|
+
if (!asset || asset.asset.visibility !== "host_private" || asset.asset.mediaType !== "application/json") {
|
|
2113
|
+
throw new Error(`Starter private initial state is missing: ${task.id}.`);
|
|
2114
|
+
}
|
|
2115
|
+
const state = JSON.parse(verifyLearningTextAsset(asset, asset.asset));
|
|
2116
|
+
if (!state || typeof state !== "object" || Array.isArray(state)) throw new Error(`Starter initial state must be a JSON object: ${task.id}.`);
|
|
2117
|
+
assertBoundedTaskJson2(state, javascript.maxStateBytes);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// src/model-taskset-resources.ts
|
|
2122
|
+
import { z as z13 } from "zod";
|
|
2123
|
+
import { EnvironmentReleaseSchema as EnvironmentReleaseSchema2, VerifierSetReleaseSchema as VerifierSetReleaseSchema2, verifyEnvironmentRelease, verifyVerifierSetRelease } from "@openpond/evals";
|
|
2124
|
+
import { createLearningTextAsset as createLearningTextAsset2, sealLearningContent as sealLearningContent2, verifyLearningTextAsset as verifyLearningTextAsset2 } from "@openpond/evals/learning";
|
|
2125
|
+
var ModelTasksetExecutionResourcesSchema = z13.object({ environment: EnvironmentReleaseSchema2, verifierSet: VerifierSetReleaseSchema2 }).strict();
|
|
2126
|
+
|
|
2127
|
+
// src/model-taskset-derivation.ts
|
|
2128
|
+
var OwnerSchema = z14.object({ scopeId: z14.string().trim().min(1).max(500), modelId: z14.string().trim().min(1).max(500) }).strict();
|
|
2129
|
+
var ModelTasksetDerivationSchema = z14.object({
|
|
2130
|
+
schemaVersion: z14.literal("openpond.modelTasksetDerivation.v1"),
|
|
2131
|
+
owner: OwnerSchema,
|
|
2132
|
+
root: ModelProjectVersionedRefSchema,
|
|
2133
|
+
parent: ModelProjectVersionedRefSchema
|
|
2134
|
+
}).strict();
|
|
2135
|
+
var ModelTasksetPackageSchema = z14.object({
|
|
2136
|
+
taskset: TasksetReleaseSchema,
|
|
2137
|
+
taskDefinition: TaskDefinitionSchema,
|
|
2138
|
+
rewardBinding: RewardBindingSchema,
|
|
2139
|
+
rewards: z14.array(RewardReleaseSchema).min(1).max(100),
|
|
2140
|
+
assets: z14.array(LearningTextAssetSchema).max(1e3),
|
|
2141
|
+
executionResources: ModelTasksetExecutionResourcesSchema.optional(),
|
|
2142
|
+
execution: ModelStarterExecutionSchema.optional()
|
|
2143
|
+
}).strict();
|
|
2144
|
+
var same = (left, right) => sealLearningContent3({ value: left }).contentHash === sealLearningContent3({ value: right }).contentHash;
|
|
2145
|
+
function validateModelTasksetPackage(value) {
|
|
2146
|
+
const result = ModelTasksetPackageSchema.parse(value);
|
|
2147
|
+
const { taskset, taskDefinition, rewardBinding, rewards, assets, execution } = result;
|
|
2148
|
+
for (const resource of [taskset, taskDefinition, rewardBinding, ...rewards, ...assets]) assertLearningContentHash(resource);
|
|
2149
|
+
assertTasksetRelease(taskset);
|
|
2150
|
+
if (rewardBinding.recipeRef) throw new Error("Resolve the Reward recipe into one standalone binding before deriving a Taskset.");
|
|
2151
|
+
if (!sameLearningRef(taskDefinition.rewardBinding, learningRef2(rewardBinding))) throw new Error("Taskset definition differs from its Reward binding.");
|
|
2152
|
+
const { policy, environment, environmentRelease, tools, capabilities, verifierSetRelease } = taskset;
|
|
2153
|
+
if (!same(taskDefinition.execution, { policy, environment, ...environmentRelease ? { environmentRelease } : {}, tools, capabilities, ...verifierSetRelease ? { verifierSetRelease } : {} })) throw new Error("Taskset definition differs from its execution resources.");
|
|
2154
|
+
if (!same(taskset.graders, compileBoundGraders(rewardBinding, rewards))) throw new Error("Taskset graders differ from its Reward binding.");
|
|
2155
|
+
if (taskset.metadata.starter !== void 0) {
|
|
2156
|
+
const metadata = z14.object({ taskDefinition: ModelProjectVersionedRefSchema, rewardBinding: ModelProjectVersionedRefSchema }).passthrough().parse(taskset.metadata.starter);
|
|
2157
|
+
if (!sameLearningRef(metadata.taskDefinition, learningRef2(taskDefinition)) || !sameLearningRef(metadata.rewardBinding, learningRef2(rewardBinding))) throw new Error("Taskset metadata differs from its immutable grading resources.");
|
|
2158
|
+
}
|
|
2159
|
+
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.");
|
|
2160
|
+
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.");
|
|
2161
|
+
const resources = result.executionResources ?? execution;
|
|
2162
|
+
if (taskset.environmentRelease && !resources) throw new Error("Deriving a Taskset requires its pinned execution resources.");
|
|
2163
|
+
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.");
|
|
2164
|
+
validateModelStarterExecution(execution, taskset, assets);
|
|
2165
|
+
if (new Set(assets.map((asset) => asset.id)).size !== assets.length) throw new Error("Taskset asset identities must be unique.");
|
|
2166
|
+
for (const asset of assets) verifyLearningTextAsset3(asset, asset.asset);
|
|
2167
|
+
for (const reference of resources ? [resources.environment.actionSchemaRef, resources.environment.observationSchemaRef, resources.environment.stateSchemaRef] : []) {
|
|
2168
|
+
if (!reference) continue;
|
|
2169
|
+
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2170
|
+
if (!asset) throw new Error(`Taskset environment asset is missing: ${reference.id}.`);
|
|
2171
|
+
verifyLearningTextAsset3(asset, reference);
|
|
2172
|
+
}
|
|
2173
|
+
for (const task of taskset.tasks) {
|
|
2174
|
+
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}.`);
|
|
2175
|
+
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}.`);
|
|
2176
|
+
}
|
|
2177
|
+
for (const reward of rewards) {
|
|
2178
|
+
const implementation = reward.implementation;
|
|
2179
|
+
const references = [...reward.assets, ..."verifierRef" in implementation ? [implementation.verifierRef] : [], ..."rubricRef" in implementation ? [implementation.rubricRef] : [], ..."inputContract" in implementation ? [implementation.inputContract] : []];
|
|
2180
|
+
for (const reference of references) {
|
|
2181
|
+
const asset = assets.find((asset2) => asset2.id === reference.id);
|
|
2182
|
+
if (!asset || reference.visibility === "policy") throw new Error(`Taskset Reward requires its private asset: ${reference.id}.`);
|
|
2183
|
+
verifyLearningTextAsset3(asset, reference);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
return result;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// src/taskset-package-contracts.ts
|
|
2190
|
+
var MAX_TASKSET_PACKAGE_BYTES = 64 * 1024 * 1024;
|
|
2191
|
+
var TasksetPackageFileSchema = z15.object({
|
|
2192
|
+
asset: ImmutableAssetRefSchema,
|
|
2193
|
+
base64: z15.string().max(Math.ceil(MAX_TASKSET_PACKAGE_BYTES / 3) * 4)
|
|
2194
|
+
}).strict();
|
|
2195
|
+
var BoundModelResourcesSchema = ModelTasksetPackageSchema.omit({ taskset: true, executionResources: true });
|
|
2196
|
+
var TasksetPackageContentSchema = z15.object({
|
|
2197
|
+
schemaVersion: z15.literal("openpond.tasksetPackage.v1"),
|
|
2198
|
+
taskset: TasksetReleaseSchema2,
|
|
2199
|
+
environment: EnvironmentReleaseSchema3,
|
|
2200
|
+
verifierSet: VerifierSetReleaseSchema3,
|
|
2201
|
+
files: z15.array(TasksetPackageFileSchema).max(1e4),
|
|
2202
|
+
modelResources: BoundModelResourcesSchema.optional()
|
|
2203
|
+
}).strict();
|
|
2204
|
+
var TasksetPackageSchema = TasksetPackageContentSchema.extend({ contentHash: z15.string().regex(/^[a-f0-9]{64}$/) }).strict();
|
|
2205
|
+
function decodeTasksetPackageFile(value) {
|
|
2206
|
+
const file = TasksetPackageFileSchema.parse(value);
|
|
2207
|
+
const raw = atob(file.base64);
|
|
2208
|
+
if (btoa(raw) !== file.base64) throw new Error(`Taskset asset ${file.asset.id} has noncanonical base64.`);
|
|
2209
|
+
const bytes = Uint8Array.from(raw, (character) => character.charCodeAt(0));
|
|
2210
|
+
if (bytes.byteLength !== file.asset.sizeBytes || sha256(bytes) !== file.asset.contentHash) throw new Error(`Taskset asset ${file.asset.id} differs from its immutable bytes.`);
|
|
2211
|
+
return bytes;
|
|
2212
|
+
}
|
|
2213
|
+
function validateTasksetPackage(value) {
|
|
2214
|
+
assertBoundedTaskJson3(value, MAX_TASKSET_PACKAGE_BYTES);
|
|
2215
|
+
const result = TasksetPackageSchema.parse(value);
|
|
2216
|
+
const { contentHash: hash, ...content } = result;
|
|
2217
|
+
if (contentHash(content) !== hash) throw new Error("Taskset package content hash differs from its bytes.");
|
|
2218
|
+
const { taskset, environment, verifierSet } = result;
|
|
2219
|
+
assertTasksetRelease2(taskset);
|
|
2220
|
+
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)) {
|
|
2221
|
+
throw new Error("Taskset package execution releases do not match its Taskset.");
|
|
2222
|
+
}
|
|
2223
|
+
const files = /* @__PURE__ */ new Map();
|
|
2224
|
+
for (const file of result.files) {
|
|
2225
|
+
if (files.has(file.asset.id)) throw new Error(`Duplicate Taskset asset identity: ${file.asset.id}.`);
|
|
2226
|
+
decodeTasksetPackageFile(file);
|
|
2227
|
+
files.set(file.asset.id, file);
|
|
2228
|
+
}
|
|
2229
|
+
function requireAsset(ref) {
|
|
2230
|
+
const file = files.get(ref.id);
|
|
2231
|
+
if (!file || !same2(file.asset, ref)) throw new Error(`Taskset package asset is missing or mismatched: ${ref.id}.`);
|
|
2232
|
+
}
|
|
2233
|
+
for (const task of taskset.tasks) {
|
|
2234
|
+
for (const asset of task.artifactRefs) requireAsset(asset);
|
|
2235
|
+
for (const output of task.requiredOutputs ?? []) if (output.schemaRef) requireAsset(output.schemaRef);
|
|
2236
|
+
if (task.privilegedContextRef && files.get(task.privilegedContextRef)?.asset.visibility !== "host_private") {
|
|
2237
|
+
throw new Error(`Taskset package private context is missing: ${task.id}.`);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
for (const ref of [environment.actionSchemaRef, environment.observationSchemaRef, environment.stateSchemaRef]) if (ref) requireAsset(ref);
|
|
2241
|
+
for (const grader of taskset.graders) {
|
|
2242
|
+
const ref = "verifierRef" in grader ? grader.verifierRef : "rubricRef" in grader ? grader.rubricRef : null;
|
|
2243
|
+
if (ref) {
|
|
2244
|
+
requireAsset(ref);
|
|
2245
|
+
if (ref.visibility === "policy") throw new Error(`Taskset grader asset must be private: ${ref.id}.`);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
for (const declarations of [taskset.metadata.environmentResources, environment.metadata.resources]) {
|
|
2249
|
+
if (declarations === void 0) continue;
|
|
2250
|
+
for (const resource of z15.array(z15.object({ path: z15.string().min(1) }).passthrough()).parse(declarations)) {
|
|
2251
|
+
if (!result.files.some((file) => file.asset.path === resource.path)) throw new Error(`Taskset environment resource is missing: ${resource.path}.`);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
if (result.modelResources) {
|
|
2255
|
+
const model = validateModelTasksetPackage({ ...result.modelResources, taskset, executionResources: { environment, verifierSet } });
|
|
2256
|
+
for (const asset of model.assets) requireAsset(asset.asset);
|
|
2257
|
+
} else if (["starter", "rewardBinding", "rewardExecution", "modelTasksetDerivation", "learning"].some((key) => taskset.metadata[key] !== void 0)) {
|
|
2258
|
+
throw new Error("Bound Taskset publication requires its complete model resources.");
|
|
2259
|
+
}
|
|
2260
|
+
return result;
|
|
2261
|
+
}
|
|
2262
|
+
function createTasksetPackage(value) {
|
|
2263
|
+
assertBoundedTaskJson3(value, MAX_TASKSET_PACKAGE_BYTES);
|
|
2264
|
+
const content = TasksetPackageContentSchema.parse(value);
|
|
2265
|
+
return validateTasksetPackage({ ...content, contentHash: contentHash(content) });
|
|
2266
|
+
}
|
|
2267
|
+
function same2(left, right) {
|
|
2268
|
+
return contentHash({ value: left }) === contentHash({ value: right });
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
// src/taskset-package-client.ts
|
|
2272
|
+
import { z as z17 } from "zod";
|
|
2273
|
+
|
|
2274
|
+
// src/taskset-catalog.ts
|
|
2275
|
+
import { z as z16 } from "zod";
|
|
2276
|
+
var IdSchema2 = z16.string().trim().min(1).max(500);
|
|
2277
|
+
var HashSchema3 = z16.string().regex(/^[a-f0-9]{64}$/);
|
|
2278
|
+
var TasksetCatalogReleaseRefSchema = z16.object({ id: IdSchema2, revision: z16.number().int().positive(), contentHash: HashSchema3 }).strict();
|
|
2279
|
+
var HostedTasksetSummarySchema = z16.object({
|
|
2280
|
+
schemaVersion: z16.literal("openpond.hostedTasksetSummary.v1"),
|
|
2281
|
+
id: IdSchema2,
|
|
2282
|
+
teamId: IdSchema2,
|
|
2283
|
+
release: TasksetCatalogReleaseRefSchema,
|
|
2284
|
+
name: z16.string().min(1).max(500),
|
|
2285
|
+
description: z16.string().max(2e4),
|
|
2286
|
+
taskCount: z16.number().int().nonnegative(),
|
|
2287
|
+
buildIntent: z16.string().min(1).max(100),
|
|
2288
|
+
methodHint: z16.string().min(1).max(100).nullable(),
|
|
2289
|
+
packageBytes: z16.number().int().nonnegative().nullable(),
|
|
2290
|
+
storedBytes: z16.number().int().nonnegative().nullable(),
|
|
2291
|
+
createdAt: z16.string().datetime({ offset: true })
|
|
2292
|
+
}).strict();
|
|
2293
|
+
var TasksetCatalogQuerySchema = z16.object({
|
|
2294
|
+
afterId: IdSchema2.optional(),
|
|
2295
|
+
limit: z16.number().int().min(1).max(100).default(30),
|
|
2296
|
+
modelProjectId: IdSchema2.optional()
|
|
2297
|
+
}).strict();
|
|
2298
|
+
var TasksetCatalogPageSchema = z16.object({
|
|
2299
|
+
items: z16.array(HostedTasksetSummarySchema).max(100),
|
|
2300
|
+
nextCursor: IdSchema2.nullable()
|
|
2301
|
+
}).strict();
|
|
2302
|
+
var TasksetCatalogErrorSchema = z16.object({
|
|
2303
|
+
code: z16.string().min(1),
|
|
2304
|
+
message: z16.string().min(1)
|
|
2305
|
+
}).strict();
|
|
2306
|
+
|
|
2307
|
+
// src/taskset-package-client.ts
|
|
2308
|
+
var IdSchema3 = z17.string().trim().min(1).max(500);
|
|
2309
|
+
var HashSchema4 = z17.string().regex(/^[a-f0-9]{64}$/);
|
|
2310
|
+
var TasksetPackagePublicationSchema = z17.object({
|
|
2311
|
+
schemaVersion: z17.literal("openpond.tasksetPackagePublication.v1"),
|
|
2312
|
+
operationId: IdSchema3,
|
|
2313
|
+
modelProjectId: IdSchema3,
|
|
2314
|
+
expectedProjectEtag: HashSchema4.nullable(),
|
|
2315
|
+
name: z17.string().trim().min(1).max(200),
|
|
2316
|
+
description: z17.string().max(5e3),
|
|
2317
|
+
buildIntent: z17.enum(["demonstrations", "preferences", "verifiable_reward", "rubric", "discovery"]),
|
|
2318
|
+
methodHint: z17.enum(["sft", "dpo", "grpo", "ppo"]).nullable(),
|
|
2319
|
+
package: TasksetPackageSchema
|
|
2320
|
+
}).strict();
|
|
2321
|
+
var TasksetPackageReceiptSchema = z17.object({
|
|
2322
|
+
schemaVersion: z17.literal("openpond.tasksetPackageReceipt.v1"),
|
|
2323
|
+
teamId: IdSchema3,
|
|
2324
|
+
modelProjectId: IdSchema3,
|
|
2325
|
+
operationId: IdSchema3,
|
|
2326
|
+
taskset: TasksetCatalogReleaseRefSchema,
|
|
2327
|
+
packageHash: HashSchema4,
|
|
2328
|
+
hostedTasksetId: IdSchema3,
|
|
2329
|
+
projectEtag: HashSchema4
|
|
2330
|
+
}).strict();
|
|
2331
|
+
var TasksetPackageReadbackSchema = z17.object({
|
|
2332
|
+
schemaVersion: z17.literal("openpond.tasksetPackageReadback.v1"),
|
|
2333
|
+
teamId: IdSchema3,
|
|
2334
|
+
modelProjectId: IdSchema3,
|
|
2335
|
+
package: TasksetPackageSchema
|
|
2336
|
+
}).strict();
|
|
2337
|
+
var OpenPondTasksetPackageError = class extends Error {
|
|
2338
|
+
constructor(status, code, message) {
|
|
2339
|
+
super(message);
|
|
2340
|
+
this.status = status;
|
|
2341
|
+
this.code = code;
|
|
2342
|
+
this.name = "OpenPondTasksetPackageError";
|
|
2343
|
+
}
|
|
2344
|
+
status;
|
|
2345
|
+
code;
|
|
2346
|
+
};
|
|
2347
|
+
var OpenPondTasksetPackageClient = class {
|
|
2348
|
+
#options;
|
|
2349
|
+
constructor(options) {
|
|
2350
|
+
const url = new URL(options.baseUrl);
|
|
2351
|
+
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.");
|
|
2352
|
+
this.#options = { ...options, baseUrl: url.toString().replace(/\/+$/, "") };
|
|
2353
|
+
}
|
|
2354
|
+
async publish(input, options = {}) {
|
|
2355
|
+
const request = TasksetPackagePublicationSchema.parse(input);
|
|
2356
|
+
validateTasksetPackage(request.package);
|
|
2357
|
+
const receipt = TasksetPackageReceiptSchema.parse(await this.#request("", "POST", request, options.signal));
|
|
2358
|
+
const release = request.package.taskset;
|
|
2359
|
+
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) {
|
|
2360
|
+
throw new OpenPondTasksetPackageError(502, "package_receipt_mismatch", "Taskset publication receipt did not match the requested package and owner.");
|
|
2361
|
+
}
|
|
2362
|
+
return receipt;
|
|
2363
|
+
}
|
|
2364
|
+
async get(modelProjectId, reference, options = {}) {
|
|
2365
|
+
const project = IdSchema3.parse(modelProjectId);
|
|
2366
|
+
const ref = TasksetCatalogReleaseRefSchema.parse(reference);
|
|
2367
|
+
const expectedPackageHash = options.expectedPackageHash === void 0 ? void 0 : HashSchema4.parse(options.expectedPackageHash);
|
|
2368
|
+
const response = TasksetPackageReadbackSchema.parse(await this.#request(`/${encodeURIComponent(project)}/${encodeURIComponent(ref.id)}/${ref.revision}/${ref.contentHash}`, "GET", void 0, options.signal));
|
|
2369
|
+
const taskset = response.package.taskset;
|
|
2370
|
+
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.");
|
|
2371
|
+
if (expectedPackageHash !== void 0 && response.package.contentHash !== expectedPackageHash) throw new OpenPondTasksetPackageError(502, "package_readback_mismatch", "Taskset package did not match the saved publication receipt.");
|
|
2372
|
+
return validateTasksetPackage(response.package);
|
|
2373
|
+
}
|
|
2374
|
+
async #request(path, method, body, signal) {
|
|
2375
|
+
const serialized = body === void 0 ? void 0 : JSON.stringify(body);
|
|
2376
|
+
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.");
|
|
2377
|
+
const response = await (this.#options.fetch ?? globalThis.fetch)(`${this.#options.baseUrl}/v1/taskset-packages${path}`, {
|
|
2378
|
+
method,
|
|
2379
|
+
headers: { Authorization: `Bearer ${this.#options.apiKey}`, "X-OpenPond-Team-Id": this.#options.teamId, Accept: "application/json", ...serialized ? { "Content-Type": "application/json" } : {} },
|
|
2380
|
+
body: serialized,
|
|
2381
|
+
signal,
|
|
2382
|
+
redirect: "error"
|
|
2383
|
+
});
|
|
2384
|
+
const reader = response.body?.getReader();
|
|
2385
|
+
if (!reader) throw new OpenPondTasksetPackageError(response.status, "empty_response", "Taskset package response was empty.");
|
|
2386
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2387
|
+
let bytes = 0;
|
|
2388
|
+
let text = "";
|
|
2389
|
+
try {
|
|
2390
|
+
while (true) {
|
|
2391
|
+
const chunk = await reader.read();
|
|
2392
|
+
if (chunk.done) break;
|
|
2393
|
+
bytes += chunk.value.byteLength;
|
|
2394
|
+
if (bytes > MAX_TASKSET_PACKAGE_BYTES) throw new OpenPondTasksetPackageError(413, "package_too_large", "Taskset response exceeds the 64 MiB envelope.");
|
|
2395
|
+
text += decoder.decode(chunk.value, { stream: true });
|
|
2396
|
+
}
|
|
2397
|
+
text += decoder.decode();
|
|
2398
|
+
} finally {
|
|
2399
|
+
await reader.cancel();
|
|
2400
|
+
reader.releaseLock();
|
|
2401
|
+
}
|
|
2402
|
+
const payload = JSON.parse(text);
|
|
2403
|
+
if (!response.ok) {
|
|
2404
|
+
const error = z17.object({ code: z17.string(), message: z17.string() }).safeParse(payload);
|
|
2405
|
+
throw new OpenPondTasksetPackageError(response.status, error.success ? error.data.code : "package_request_failed", error.success ? error.data.message : `Taskset package request failed (${response.status}).`);
|
|
2406
|
+
}
|
|
2407
|
+
return payload;
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
export {
|
|
2411
|
+
MAX_TASKSET_PACKAGE_BYTES,
|
|
2412
|
+
OpenPondTasksetPackageClient,
|
|
2413
|
+
OpenPondTasksetPackageError,
|
|
2414
|
+
TasksetPackageContentSchema,
|
|
2415
|
+
TasksetPackageFileSchema,
|
|
2416
|
+
TasksetPackagePublicationSchema,
|
|
2417
|
+
TasksetPackageReadbackSchema,
|
|
2418
|
+
TasksetPackageReceiptSchema,
|
|
2419
|
+
TasksetPackageSchema,
|
|
2420
|
+
createTasksetPackage,
|
|
2421
|
+
decodeTasksetPackageFile,
|
|
2422
|
+
validateTasksetPackage
|
|
2423
|
+
};
|
|
2424
|
+
//# sourceMappingURL=taskset-packages.js.map
|