openpond-sdk 0.12.17 → 0.12.19
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/TRAINING_WORKFLOWS.md +15 -0
- package/dist/{chunk-VPK3SM45.js → chunk-BJMENXR4.js} +2 -1
- package/dist/{chunk-VPK3SM45.js.map → chunk-BJMENXR4.js.map} +1 -1
- package/dist/learning.js +2 -2
- package/dist/learning.js.map +1 -1
- package/dist/post-training.js +1 -1
- package/dist/training-bundle.js +1 -1
- package/dist/training.js +1102 -971
- package/dist/training.js.map +1 -1
- package/dist/types/packages/sdk/src/dataset-training-review.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts +1057 -57
- package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/experiment-evaluation-schedules.d.ts +216 -216
- package/dist/types/packages/sdk/src/experiment-improvement-client.d.ts +1889 -1889
- package/dist/types/packages/sdk/src/managed-training-preparation.d.ts +25 -25
- package/dist/types/packages/sdk/src/model-taskset-runs.d.ts +216 -216
- package/dist/types/packages/sdk/src/post-training.d.ts +1 -0
- package/dist/types/packages/sdk/src/post-training.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/steering-model-serving.d.ts +1349 -1349
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +120 -120
- package/dist/types/packages/sdk/src/training-experiment-learning-intent.d.ts +26 -0
- package/dist/types/packages/sdk/src/training-experiment-learning-intent.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/training-experiment-learning.d.ts +699 -0
- package/dist/types/packages/sdk/src/training-experiment-learning.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/training-experiment-setup.d.ts +573 -0
- package/dist/types/packages/sdk/src/training-experiment-setup.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/training-harness-sources.d.ts +2 -2
- package/dist/types/packages/sdk/src/training-learning-batch.d.ts +40 -40
- package/dist/types/packages/sdk/src/training-qualification-preparation.d.ts +25 -25
- package/dist/types/packages/sdk/src/training.d.ts +1178 -1064
- package/dist/types/packages/sdk/src/training.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/training.js
CHANGED
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
import {
|
|
73
73
|
TrainingHandoffOriginSchema,
|
|
74
74
|
createPostTrainingClient
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-BJMENXR4.js";
|
|
76
76
|
import {
|
|
77
77
|
validateHarnessPolicySourcePackage,
|
|
78
78
|
validateHarnessSourcePackage
|
|
@@ -118,7 +118,9 @@ import {
|
|
|
118
118
|
createTrainingGpuCatalogClient,
|
|
119
119
|
parseAndVerifyTrainingGpuCatalog
|
|
120
120
|
} from "./chunk-MVAEE5EI.js";
|
|
121
|
-
import
|
|
121
|
+
import {
|
|
122
|
+
ModelInitialLearningSchema
|
|
123
|
+
} from "./chunk-CL3IOOVL.js";
|
|
122
124
|
import {
|
|
123
125
|
OPENPOND_TRAINING_MEDIA_TYPE,
|
|
124
126
|
OPENPOND_TRAINING_PROTOCOL_MAJOR,
|
|
@@ -133,7 +135,8 @@ import {
|
|
|
133
135
|
parseBoundedJson
|
|
134
136
|
} from "./chunk-B3ZHJ2KK.js";
|
|
135
137
|
import {
|
|
136
|
-
ImmutableReleaseRefSchema
|
|
138
|
+
ImmutableReleaseRefSchema,
|
|
139
|
+
contentHash
|
|
137
140
|
} from "./chunk-H3JZ3P5T.js";
|
|
138
141
|
import "./chunk-YLJ4XMA6.js";
|
|
139
142
|
|
|
@@ -255,8 +258,8 @@ async function verifyManagedServingUsageBilling(value, expected, control2) {
|
|
|
255
258
|
if (await canonicalSha256(usage) !== await canonicalSha256(control2?.usage ?? null))
|
|
256
259
|
throw new OpenPondProtocolError("managed_serving_usage_mismatch", "Serving usage differs from the retained deployment owner.");
|
|
257
260
|
if (!review) return;
|
|
258
|
-
const { contentHash, ...content } = review;
|
|
259
|
-
if (
|
|
261
|
+
const { contentHash: contentHash2, ...content } = review;
|
|
262
|
+
if (contentHash2 !== await canonicalSha256(content) || review.teamId !== expected.teamId || review.modelProjectId !== expected.modelProjectId || review.versionHash !== expected.versionHash || review.method !== expected.method || Date.parse(review.expiresAt) > Date.parse(review.workDeadlineAt) || usage && (usage.reviewHash !== contentHash2 || await canonicalSha256(usage.price) !== await canonicalSha256(review.price)))
|
|
260
263
|
throw new OpenPondProtocolError("managed_serving_usage_mismatch", "Serving pricing differs from the exact saved Model, runtime or accepted terms.");
|
|
261
264
|
}
|
|
262
265
|
function managedServingUsageApprovalMatches(request, control2) {
|
|
@@ -267,12 +270,12 @@ function managedServingUsageApprovalMatches(request, control2) {
|
|
|
267
270
|
}
|
|
268
271
|
async function createManagedServingUsageApproval(rawReview, spendingLimit) {
|
|
269
272
|
const review = ManagedServingUsageReviewSchema.parse(rawReview);
|
|
270
|
-
const { contentHash, ...content } = review;
|
|
271
|
-
if (
|
|
273
|
+
const { contentHash: contentHash2, ...content } = review;
|
|
274
|
+
if (contentHash2 !== await canonicalSha256(content) || Date.parse(review.expiresAt) <= Date.now() || Date.parse(review.workDeadlineAt) <= Date.now())
|
|
272
275
|
throw new OpenPondProtocolError("managed_serving_review_expired", "Refresh the exact Model's serving price before activation.");
|
|
273
276
|
return ManagedServingUsageApprovalSchema.parse({
|
|
274
277
|
schemaVersion: "openpond.managedServingUsageApproval.v1",
|
|
275
|
-
reviewHash:
|
|
278
|
+
reviewHash: contentHash2,
|
|
276
279
|
customerCapUsd: canonicalComputeSpendCap(spendingLimit)
|
|
277
280
|
});
|
|
278
281
|
}
|
|
@@ -346,8 +349,8 @@ async function createNeuronSteeringProfile(raw) {
|
|
|
346
349
|
return { ...content, contentHash: await canonicalSha256(content) };
|
|
347
350
|
}
|
|
348
351
|
async function parseAndVerifyNeuronSteeringProfile(raw, model) {
|
|
349
|
-
const value = NeuronSteeringProfileSchema.parse(raw), { contentHash, ...content } = value;
|
|
350
|
-
if (
|
|
352
|
+
const value = NeuronSteeringProfileSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
353
|
+
if (contentHash2 !== await canonicalSha256(content) || model && await canonicalSha256(value.model) !== await canonicalSha256(NeuronSteeringModelSchema.parse(model)))
|
|
351
354
|
throw new OpenPondProtocolError("neuron_steering_profile_mismatch", "The intervention differs from its exact model or retained payload.");
|
|
352
355
|
return value;
|
|
353
356
|
}
|
|
@@ -370,8 +373,8 @@ var NeuronResidualCalibrationContentSchema = z2.object({
|
|
|
370
373
|
});
|
|
371
374
|
var NeuronResidualCalibrationSchema = NeuronResidualCalibrationContentSchema.safeExtend({ contentHash: Hash2 });
|
|
372
375
|
async function parseAndVerifyNeuronResidualCalibration(raw, model, reference) {
|
|
373
|
-
const value = NeuronResidualCalibrationSchema.parse(raw), { contentHash, ...content } = value;
|
|
374
|
-
if (
|
|
376
|
+
const value = NeuronResidualCalibrationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
377
|
+
if (contentHash2 !== await canonicalSha256(content) || value.modelHash !== await canonicalSha256(NeuronSteeringModelSchema.parse(model)) || reference && (reference.id !== value.id || reference.revision !== value.revision || reference.contentHash !== value.contentHash) || value.layers.some((layer) => layer.layer >= model.intermediateSizes.length))
|
|
375
378
|
throw new OpenPondProtocolError("neuron_calibration_mismatch", "The residual calibration differs from its exact model or immutable reference.");
|
|
376
379
|
return value;
|
|
377
380
|
}
|
|
@@ -501,11 +504,11 @@ function engramAdapterTensorInventory(config, hiddenSize) {
|
|
|
501
504
|
return items.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
502
505
|
}
|
|
503
506
|
async function parseAndVerifyEngramAdapterArtifact(raw, expected) {
|
|
504
|
-
const value = EngramAdapterArtifactSchema.parse(raw), { contentHash, ...content } = value;
|
|
507
|
+
const value = EngramAdapterArtifactSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
505
508
|
const fail8 = () => {
|
|
506
509
|
throw new OpenPondProtocolError("engram_artifact_mismatch", "The Engram module differs from its exact configuration, data or parent.");
|
|
507
510
|
};
|
|
508
|
-
if (
|
|
511
|
+
if (contentHash2 !== await canonicalSha256(content) || value.pins.adapterConfigHash !== await canonicalSha256(value.config) || value.pins.dataHash !== await canonicalSha256(value.pins.data) || new Set(value.payload.tensors.map((row) => row.name)).size !== value.payload.tensors.length || canonicalJson([...value.payload.tensors].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) !== canonicalJson(engramAdapterTensorInventory(value.config, value.pins.baseModel.hiddenSize))) fail8();
|
|
509
512
|
if (expected) {
|
|
510
513
|
const request = await parseAndVerifyEngramTrainingRequest(expected.request);
|
|
511
514
|
if (canonicalJson(value.config) !== canonicalJson(request.config) || canonicalJson(value.pins.baseModel) !== canonicalJson(request.model) || canonicalJson(value.pins.data) !== canonicalJson(request.data) || value.pins.recipeHash !== await canonicalSha256(request.training) || value.pins.runtimeHash !== expected.runtimeHash || value.pins.parentArtifactHash !== (request.parentArtifact?.contentHash ?? null) || value.payload.sizeBytes > request.training.maxCheckpointBytes) fail8();
|
|
@@ -546,11 +549,11 @@ var EngramTrainingResultContentSchema = z3.object({
|
|
|
546
549
|
var EngramTrainingResultSchema = EngramTrainingResultContentSchema.extend({ contentHash: Hash3 });
|
|
547
550
|
async function parseAndVerifyEngramTrainingResult(raw, expected) {
|
|
548
551
|
const request = await parseAndVerifyEngramTrainingRequest(expected.request);
|
|
549
|
-
const value = EngramTrainingResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
552
|
+
const value = EngramTrainingResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
550
553
|
const manifest = await parseAndVerifyEngramAdapterArtifact(value.artifact.manifest, expected);
|
|
551
554
|
const tensor = value.artifact.files.find((file2) => file2.path === "adapter.safetensors");
|
|
552
555
|
const metadata = value.artifact.files.find((file2) => file2.path === "manifest.json");
|
|
553
|
-
if (
|
|
556
|
+
if (contentHash2 !== await canonicalSha256(content) || value.inputHash !== await canonicalSha256(request) || value.modelHash !== await canonicalSha256(request.model) || value.dataHash !== await canonicalSha256(request.data) || value.runtimeHash !== expected.runtimeHash || value.optimizerSteps !== request.training.maxSteps || value.examplesProcessed !== value.optimizerSteps * request.training.gradientAccumulationSteps || value.targetTokens > value.forwardTokenWork || value.durationMs > request.training.maxDurationSeconds * 1e3 || value.baseWeightsHashBefore !== request.model.weightsHash || value.baseWeightsHashAfter !== value.baseWeightsHashBefore || value.artifact.contentHash !== manifest.contentHash || !tensor || !metadata || metadata.sizeBytes > 262144 || metadata.sha256 !== await canonicalSha256(manifest) || metadata.sizeBytes !== new TextEncoder().encode(canonicalJson(manifest)).byteLength || tensor.sha256 !== manifest.payload.sha256 || tensor.sizeBytes !== manifest.payload.sizeBytes || value.artifact.files.some((file2) => file2.artifactId !== value.artifact.id) || value.artifact.files.reduce((total, file2) => total + file2.sizeBytes, 0) > request.training.maxCheckpointBytes)
|
|
554
557
|
throw new OpenPondProtocolError("engram_training_result_mismatch", "The Engram training result differs from its exact run, frozen base or committed module.");
|
|
555
558
|
return value;
|
|
556
559
|
}
|
|
@@ -577,10 +580,10 @@ var SavedEngramExperimentSourceSchema = z4.object({
|
|
|
577
580
|
modelHash: Hash4
|
|
578
581
|
}).strict();
|
|
579
582
|
async function parseAndVerifyEngramModelVersion(raw, expected = {}) {
|
|
580
|
-
const value = EngramModelVersionSchema.parse(raw), { contentHash, ...content } = value;
|
|
583
|
+
const value = EngramModelVersionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
581
584
|
const manifest = await parseAndVerifyEngramAdapterArtifact(value.artifact.manifest);
|
|
582
585
|
const files = value.artifact.files, metadata = files.find((file2) => file2.path === "manifest.json"), tensor = files.find((file2) => file2.path === "adapter.safetensors");
|
|
583
|
-
if (
|
|
586
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId && value.teamId !== expected.teamId || expected.modelProjectId && value.modelProjectId !== expected.modelProjectId || expected.ownerUserId && value.ownerUserId !== expected.ownerUserId || value.baseModel.modelId !== manifest.pins.baseModel.modelId || value.baseModel.revision !== manifest.pins.baseModel.revision || value.source.runtimeHash !== manifest.pins.runtimeHash || value.artifact.contentHash !== manifest.contentHash || !metadata || !tensor || metadata.sha256 !== await canonicalSha256(manifest) || metadata.sizeBytes !== new TextEncoder().encode(canonicalJson(manifest)).byteLength || tensor.sha256 !== manifest.payload.sha256 || tensor.sizeBytes !== manifest.payload.sizeBytes || files.some((file2) => file2.artifactId !== value.artifact.id))
|
|
584
587
|
throw new OpenPondProtocolError("engram_model_version_mismatch", "The saved Model differs from its exact trained memory module.");
|
|
585
588
|
return value;
|
|
586
589
|
}
|
|
@@ -608,9 +611,9 @@ var EngramResultSaveReceiptContentSchema = z4.object({
|
|
|
608
611
|
}).strict();
|
|
609
612
|
var EngramResultSaveReceiptSchema = EngramResultSaveReceiptContentSchema.extend({ contentHash: Hash4 });
|
|
610
613
|
async function parseAndVerifyEngramResultSaveReceipt(raw, input) {
|
|
611
|
-
const request = EngramResultSaveRequestSchema.parse(input), value = EngramResultSaveReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
614
|
+
const request = EngramResultSaveRequestSchema.parse(input), value = EngramResultSaveReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
612
615
|
await parseAndVerifyEngramModelVersion(value.version, { teamId: request.teamId, modelProjectId: value.model.id, ownerUserId: value.actorId });
|
|
613
|
-
if (
|
|
616
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== request.teamId || value.model.teamId !== request.teamId || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256(request) || value.version.source.executionId !== request.executionId || value.version.source.resultHash !== request.resultHash || value.version.artifact.contentHash !== request.artifactHash || value.model.name !== request.name || value.model.revision !== request.expectedModelRevision + 1 || request.modelProjectId && value.model.id !== request.modelProjectId || value.version.portableProjectId !== value.model.portableProjectId)
|
|
614
617
|
throw new OpenPondProtocolError("engram_model_save_mismatch", "The saved Model differs from the original execution, module or Model revision.");
|
|
615
618
|
return value;
|
|
616
619
|
}
|
|
@@ -687,9 +690,9 @@ var EngramInferenceReceiptContentSchema = z6.object({
|
|
|
687
690
|
}).strict();
|
|
688
691
|
var EngramInferenceReceiptSchema = EngramInferenceReceiptContentSchema.extend({ contentHash: Hash5 });
|
|
689
692
|
async function parseAndVerifyEngramInferenceReceipt(raw, expected) {
|
|
690
|
-
const value = EngramInferenceReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
693
|
+
const value = EngramInferenceReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
691
694
|
parseAndVerifyResolvedEngramSelection(value.selection, expected.options);
|
|
692
|
-
if (
|
|
695
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.requestId !== expected.requestId || value.requestHash !== expected.requestHash || canonicalJson(value.selection) !== canonicalJson(expected.selection) || value.poolId !== expected.poolId || canonicalJson(value.routingBinding) !== canonicalJson(expected.routingBinding) || value.runtimeHash !== expected.runtimeHash || value.workerImageDigest !== expected.workerImageDigest || value.engineGeneration !== expected.engineGeneration || value.cacheNamespace !== expected.cacheNamespace)
|
|
693
696
|
throw new OpenPondProtocolError("engram_inference_receipt_mismatch", "The completed inference differs from its admitted memory module, runtime or cache.");
|
|
694
697
|
return value;
|
|
695
698
|
}
|
|
@@ -787,20 +790,20 @@ function engramModelServingState(value) {
|
|
|
787
790
|
}
|
|
788
791
|
async function parseAndVerifyEngramModelServingControl(raw, expected) {
|
|
789
792
|
const value = EngramModelServingControlReceiptSchema.parse(raw), request = EngramModelServingControlRequestSchema.parse(expected.request);
|
|
790
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
793
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
791
794
|
await parseAndVerifyEngramModelVersion(value.version, { teamId: request.teamId, modelProjectId: expected.modelProjectId });
|
|
792
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
795
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || canonicalJson(value.request) !== canonicalJson(request) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || expected.actorId && value.actorId !== expected.actorId || value.version.contentHash !== request.versionHash || control2.teamId !== value.teamId || control2.modelProjectId !== value.modelProjectId || control2.actorId !== value.actorId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || control2.defaultEnabled !== request.defaultEnabled || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || !validControl(control2) || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
793
796
|
throw new OpenPondProtocolError("engram_serving_control_mismatch", "The serving receipt differs from the exact memory Model or original command.");
|
|
794
797
|
return value;
|
|
795
798
|
}
|
|
796
799
|
async function parseAndVerifyEngramModelServing(raw, expected) {
|
|
797
|
-
const value = EngramModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
800
|
+
const value = EngramModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
798
801
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "engram" }, value.control);
|
|
799
802
|
await parseAndVerifyEngramModelVersion(value.version, expected);
|
|
800
803
|
function fail8() {
|
|
801
804
|
throw new OpenPondProtocolError("engram_model_serving_mismatch", "The serving evidence differs from the exact memory Model or retained capacity.");
|
|
802
805
|
}
|
|
803
|
-
if (
|
|
806
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || value.state !== engramModelServingState(value) || value.availability.state === "qualified" !== (value.availability.reason === "qualified") || value.availability.state === "qualified" && value.availability.runtimeHash === null) fail8();
|
|
804
807
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
805
808
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
806
809
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl(control3)) fail8();
|
|
@@ -956,11 +959,11 @@ var ActivationReferenceResultContentSchema = z10.object({
|
|
|
956
959
|
}).strict();
|
|
957
960
|
var ActivationReferenceResultSchema = ActivationReferenceResultContentSchema.extend({ contentHash: Hash8 }).strict();
|
|
958
961
|
async function parseAndVerifyActivationReferenceResult(raw, input) {
|
|
959
|
-
const request = await parseAndVerifyActivationReferenceRequest(input), value = ActivationReferenceResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
962
|
+
const request = await parseAndVerifyActivationReferenceRequest(input), value = ActivationReferenceResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
960
963
|
const fail8 = () => {
|
|
961
964
|
throw new OpenPondProtocolError("activation_reference_result_mismatch", "The inspection differs from its exact prompt, model, intervention or capture bounds.");
|
|
962
965
|
};
|
|
963
|
-
if (
|
|
966
|
+
if (contentHash2 !== await canonicalSha256(content) || value.requestHash !== await canonicalSha256(request) || value.modelHash !== await canonicalSha256(request.model) || value.captures.length * 2 > request.maximumCapturedValues || value.outcomes.length !== request.prompts.length * request.variants.length || value.outcomes.reduce((sum, row) => sum + row.forwardTokenWork, 0) > request.maximumForwardTokenWork) fail8();
|
|
964
967
|
const pairs = /* @__PURE__ */ new Set(), counts = /* @__PURE__ */ new Map(), captureKeys = /* @__PURE__ */ new Set();
|
|
965
968
|
const prompts = new Map(request.prompts.map((row) => [row.id, row])), variants = new Map(request.variants.map((row) => [row.id, row]));
|
|
966
969
|
for (const capture of value.captures) {
|
|
@@ -1024,8 +1027,8 @@ var TrainingModelVersionContentSchema = z11.object({
|
|
|
1024
1027
|
var TrainingModelVersionSchema = TrainingModelVersionContentSchema.extend({ contentHash: Hash9 }).strict();
|
|
1025
1028
|
async function parseAndVerifyTrainingModelVersion(raw, expected = {}) {
|
|
1026
1029
|
const value = TrainingModelVersionSchema.parse(raw);
|
|
1027
|
-
const { contentHash, ...content } = value;
|
|
1028
|
-
if (
|
|
1030
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
1031
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId && value.teamId !== expected.teamId || expected.modelProjectId && value.modelProjectId !== expected.modelProjectId || expected.jobId && value.jobId !== expected.jobId || value.request.source.modelProject.id !== value.modelProjectId || value.request.source.modelProject.portableProjectId !== value.portableProjectId || value.candidate.composition === "base" !== (value.candidate.parent === null))
|
|
1029
1032
|
throw new OpenPondProtocolError("training_model_version_mismatch", "The saved Model version differs from its original training result.");
|
|
1030
1033
|
return value;
|
|
1031
1034
|
}
|
|
@@ -1044,11 +1047,11 @@ var TrainingResultContentSchema = z11.object({
|
|
|
1044
1047
|
var TrainingResultSchema = TrainingResultContentSchema.extend({ contentHash: Hash9 }).strict();
|
|
1045
1048
|
async function parseAndVerifyTrainingResult(raw, expected) {
|
|
1046
1049
|
const value = TrainingResultSchema.parse(raw);
|
|
1047
|
-
const { contentHash, ...content } = value;
|
|
1050
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
1048
1051
|
function fail8() {
|
|
1049
1052
|
throw new OpenPondProtocolError("training_result_mismatch", "The trained result differs from its producing Job, request or outputs.");
|
|
1050
1053
|
}
|
|
1051
|
-
if (
|
|
1054
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== value.job.teamId || value.job.id !== expected.jobId || expected.teamId && value.teamId !== expected.teamId || value.outputs.outputs.some((output) => output.jobId !== value.job.id) || new Set(value.outputs.outputs.map((output) => output.id)).size !== value.outputs.outputs.length) fail8();
|
|
1052
1055
|
if (value.model && (value.model.id !== value.job.modelProjectId || value.model.teamId !== value.teamId || value.model.portableProjectId !== value.job.portableProjectId)) fail8();
|
|
1053
1056
|
const request = value.request;
|
|
1054
1057
|
if (request && (request.submissionHash !== value.job.submissionHash || request.source.modelProject.id !== value.job.modelProjectId || request.source.modelProject.portableProjectId !== value.job.portableProjectId || request.source.modelProject.revision !== value.job.sourceProjectRevision)) fail8();
|
|
@@ -1322,11 +1325,11 @@ var DecisionScoringResultSchema = DecisionScoringResultContentSchema.extend({ co
|
|
|
1322
1325
|
async function parseAndVerifyDecisionScoringResult(raw, expected) {
|
|
1323
1326
|
assertBoundedTaskJson(raw, 131072);
|
|
1324
1327
|
const request = await parseAndVerifyDecisionScoringRequest(expected.request);
|
|
1325
|
-
const value = DecisionScoringResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
1328
|
+
const value = DecisionScoringResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1326
1329
|
const fail8 = () => {
|
|
1327
1330
|
throw new OpenPondProtocolError("decision_score_mismatch", "The decision distributions differ from the exact request, complete T1 candidate scores or runtime.");
|
|
1328
1331
|
};
|
|
1329
|
-
if (
|
|
1332
|
+
if (contentHash2 !== await canonicalSha256(content) || value.requestHash !== await canonicalSha256(request) || value.modelHash !== await canonicalSha256(request.model) || value.runtimeHash !== Hash11.parse(expected.runtimeHash) || canonicalJson(value.artifact) !== canonicalJson(request.artifact) || value.distributions.length !== request.input.questions.length || value.forwardTokenWork > request.limits.maximumForwardTokenWork || value.durationMs > request.limits.maximumDurationSeconds * 1e3) fail8();
|
|
1330
1333
|
let promptWork = 0;
|
|
1331
1334
|
for (const [index, question2] of request.input.questions.entries()) {
|
|
1332
1335
|
const row = value.distributions[index];
|
|
@@ -1478,12 +1481,12 @@ var DecisionAdapterArtifactContentSchema = z14.object({
|
|
|
1478
1481
|
}).strict();
|
|
1479
1482
|
var DecisionAdapterArtifactSchema = DecisionAdapterArtifactContentSchema.extend({ contentHash: Hash12 });
|
|
1480
1483
|
async function parseAndVerifyDecisionAdapterArtifact(raw, expected) {
|
|
1481
|
-
const value = DecisionAdapterArtifactSchema.parse(raw), { contentHash, ...content } = value;
|
|
1484
|
+
const value = DecisionAdapterArtifactSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1482
1485
|
await parseAndVerifyDecisionModelIdentity(value.model);
|
|
1483
1486
|
const fail8 = () => {
|
|
1484
1487
|
throw new OpenPondProtocolError("decision_artifact_mismatch", "The decision artifact differs from its exact hybrid module, source, recipe or data.");
|
|
1485
1488
|
};
|
|
1486
|
-
if (
|
|
1489
|
+
if (contentHash2 !== await canonicalSha256(content) || canonicalJson(value.contract) !== canonicalJson(await decisionArtifactContract(value.model)) || canonicalJson(value.payload.tensors) !== canonicalJson(decisionAdapterTensorInventory()) || value.payload.sizeBytes < value.payload.tensors.reduce((sum, row) => sum + row.shape[0] * row.shape[1] * 4, 0)) fail8();
|
|
1487
1490
|
if (expected && (canonicalJson(value.model) !== canonicalJson(expected.model) || value.pins.inputHash !== expected.inputHash || value.pins.recipeHash !== expected.recipeHash || value.pins.dataHash !== expected.dataHash || value.pins.runtimeHash !== expected.runtimeHash || value.pins.parentArtifactHash !== expected.parentArtifactHash)) fail8();
|
|
1488
1491
|
return value;
|
|
1489
1492
|
}
|
|
@@ -1597,7 +1600,7 @@ var DecisionTrainingResultSchema = DecisionTrainingResultContentSchema.extend({
|
|
|
1597
1600
|
async function parseAndVerifyDecisionTrainingResult(raw, expected) {
|
|
1598
1601
|
assertBoundedTaskJson2(raw, 524288);
|
|
1599
1602
|
const request = await parseAndVerifyDecisionTrainingRequest(expected.request);
|
|
1600
|
-
const value = DecisionTrainingResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
1603
|
+
const value = DecisionTrainingResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1601
1604
|
const manifest = await parseAndVerifyDecisionAdapterArtifact(value.artifact.manifest, {
|
|
1602
1605
|
model: request.model,
|
|
1603
1606
|
inputHash: await canonicalSha256(request),
|
|
@@ -1609,7 +1612,7 @@ async function parseAndVerifyDecisionTrainingResult(raw, expected) {
|
|
|
1609
1612
|
const fail8 = () => {
|
|
1610
1613
|
throw new OpenPondProtocolError("decision_training_result_mismatch", "The decision result differs from its exact run, frozen backbone evidence or committed artifact.");
|
|
1611
1614
|
};
|
|
1612
|
-
if (
|
|
1615
|
+
if (contentHash2 !== await canonicalSha256(content) || value.inputHash !== manifest.pins.inputHash || value.modelHash !== await canonicalSha256(request.model) || value.runtimeHash !== expected.runtimeHash || value.dataHash !== manifest.pins.dataHash || value.initialAdapterSourceHash !== (request.parentArtifact?.contentHash ?? request.model.originalAdapter.contentHash) || value.optimizerSteps !== request.training.maxSteps || value.questionRowsProcessed !== value.optimizerSteps * request.training.gradientAccumulationSteps || value.examplesProcessed > value.questionRowsProcessed || value.targetTokens !== value.questionRowsProcessed || value.forwardTokenWork < value.questionRowsProcessed || value.forwardTokenWork > value.questionRowsProcessed * request.training.maximumPromptTokens || value.durationMs > request.training.maxDurationSeconds * 1e3 || value.frozenBackboneState.sourceManifestHash !== request.model.backbone.source.contentHash || value.frozenBackboneState.before !== value.frozenBackboneState.after || value.artifact.contentHash !== manifest.contentHash || new Set(value.artifact.files.map((file2) => file2.path)).size !== 4 || value.artifact.files.some((file2) => file2.artifactId !== value.artifact.id) || value.artifact.files.reduce((sum, file2) => sum + file2.sizeBytes, 0) > request.training.maxCheckpointBytes) fail8();
|
|
1613
1616
|
const tensor = value.artifact.files.find((file2) => file2.path === "adapter_model.safetensors");
|
|
1614
1617
|
if (!tensor || tensor.sha256 !== manifest.payload.sha256 || tensor.sizeBytes !== manifest.payload.sizeBytes) fail8();
|
|
1615
1618
|
for (const [path, payload] of [
|
|
@@ -1707,7 +1710,7 @@ var DecisionModelVersionContentSchema = z17.object({
|
|
|
1707
1710
|
var DecisionModelVersionSchema = DecisionModelVersionContentSchema.extend({ contentHash: Hash15 });
|
|
1708
1711
|
async function parseAndVerifyDecisionModelVersion(raw, expected = {}) {
|
|
1709
1712
|
assertBoundedTaskJson3(raw, 524288);
|
|
1710
|
-
const value = DecisionModelVersionSchema.parse(raw), { contentHash, ...content } = value;
|
|
1713
|
+
const value = DecisionModelVersionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1711
1714
|
const request = await parseAndVerifyDecisionTrainingRequest(value.request);
|
|
1712
1715
|
const manifest = await parseAndVerifyDecisionAdapterArtifact(value.artifact.manifest, {
|
|
1713
1716
|
model: request.model,
|
|
@@ -1720,7 +1723,7 @@ async function parseAndVerifyDecisionModelVersion(raw, expected = {}) {
|
|
|
1720
1723
|
function fail8() {
|
|
1721
1724
|
throw new OpenPondProtocolError("decision_model_version_mismatch", "The saved decision Model differs from its exact trained source, runtime or committed artifact.");
|
|
1722
1725
|
}
|
|
1723
|
-
if (
|
|
1726
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId !== void 0 && value.teamId !== expected.teamId || expected.modelProjectId !== void 0 && value.modelProjectId !== expected.modelProjectId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || expected.versionHash !== void 0 && value.contentHash !== expected.versionHash || canonicalJson(value.baseModel) !== canonicalJson(request.model.source) || value.source.inputHash !== manifest.pins.inputHash || value.artifact.contentHash !== manifest.contentHash || new Set(value.artifact.files.map((file2) => file2.path)).size !== 4 || value.artifact.files.some((file2) => file2.artifactId !== value.artifact.id) || value.artifact.files.reduce((sum, file2) => sum + file2.sizeBytes, 0) > request.training.maxCheckpointBytes) fail8();
|
|
1724
1727
|
const tensor = value.artifact.files.find((file2) => file2.path === "adapter_model.safetensors");
|
|
1725
1728
|
if (!tensor || tensor.sha256 !== manifest.payload.sha256 || tensor.sizeBytes !== manifest.payload.sizeBytes) fail8();
|
|
1726
1729
|
for (const [path, payload] of [
|
|
@@ -1778,9 +1781,9 @@ var DecisionResultSaveReceiptContentSchema = z17.object({
|
|
|
1778
1781
|
}).strict();
|
|
1779
1782
|
var DecisionResultSaveReceiptSchema = DecisionResultSaveReceiptContentSchema.extend({ contentHash: Hash15 });
|
|
1780
1783
|
async function parseAndVerifyDecisionResultSaveReceipt(raw, input, actorId) {
|
|
1781
|
-
const request = DecisionResultSaveRequestSchema.parse(input), value = DecisionResultSaveReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
1784
|
+
const request = DecisionResultSaveRequestSchema.parse(input), value = DecisionResultSaveReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1782
1785
|
await parseAndVerifyDecisionModelVersion(value.version, { teamId: request.teamId, modelProjectId: value.model.id, ownerUserId: value.actorId });
|
|
1783
|
-
if (
|
|
1786
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== request.teamId || value.model.teamId !== request.teamId || actorId !== void 0 && value.actorId !== actorId || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256(request) || value.version.source.executionId !== request.executionId || value.version.source.resultHash !== request.resultHash || value.version.artifact.contentHash !== request.artifactHash || value.model.name !== request.name || value.model.revision !== request.expectedModelRevision + 1 || request.modelProjectId !== null && value.model.id !== request.modelProjectId || value.version.portableProjectId !== value.model.portableProjectId)
|
|
1784
1787
|
throw new OpenPondProtocolError("decision_model_save_mismatch", "The saved Model differs from the original decision training result, artifact or Model revision.");
|
|
1785
1788
|
return value;
|
|
1786
1789
|
}
|
|
@@ -1938,12 +1941,12 @@ var AlphaEditArtifactContentSchema = z19.object({
|
|
|
1938
1941
|
var AlphaEditArtifactSchema = AlphaEditArtifactContentSchema.extend({ contentHash: AlphaEditHashSchema });
|
|
1939
1942
|
var order = (items) => [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
1940
1943
|
async function parseAndVerifyAlphaEditArtifact(raw, expected) {
|
|
1941
|
-
const value = AlphaEditArtifactSchema.parse(raw), { contentHash, ...content } = value;
|
|
1944
|
+
const value = AlphaEditArtifactSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
1942
1945
|
const inventory = alphaEditTensorInventory(value.config);
|
|
1943
1946
|
const fail8 = () => {
|
|
1944
1947
|
throw new OpenPondProtocolError("alphaedit_artifact_mismatch", "The AlphaEdit matrix patch differs from its exact model, state or input.");
|
|
1945
1948
|
};
|
|
1946
|
-
if (
|
|
1949
|
+
if (contentHash2 !== await canonicalSha256(content) || value.pins.configHash !== await canonicalSha256(value.config) || value.pins.dataHash !== await canonicalSha256(value.pins.data) || value.pins.preservationModelHash !== await canonicalSha256(value.pins.baseModel) || value.payloads.patch.sizeBytes < value.config.layers.length * 4096 * 12288 * 2 || value.payloads.state.length !== value.config.layers.length || canonicalJson(order(value.payloads.patch.tensors)) !== canonicalJson(order(inventory.patch)) || value.payloads.state.some((payload, index) => payload.path !== `state-${value.config.layers[index]}.safetensors` || payload.sizeBytes < 3 * 12288 * 12288 * 4 || canonicalJson(order(payload.tensors)) !== canonicalJson(order(inventory.state.filter((tensor) => tensor.name.startsWith(`layers.${value.config.layers[index]}.`)))))) fail8();
|
|
1947
1950
|
if (expected) {
|
|
1948
1951
|
const request = AlphaEditTrainingRequestSchema.parse(expected.request);
|
|
1949
1952
|
if (canonicalJson(value.pins.baseModel) !== canonicalJson(request.model) || canonicalJson(value.config) !== canonicalJson(request.config) || canonicalJson(value.pins.data) !== canonicalJson(request.data) || value.pins.recipeHash !== await canonicalSha256(request.training) || value.pins.runtimeHash !== expected.runtimeHash || value.pins.parentArtifactHash !== (request.parentArtifact?.contentHash ?? null) || value.payloads.patch.sizeBytes + value.payloads.state.reduce((sum, payload) => sum + payload.sizeBytes, 0) > request.training.maxCheckpointBytes) fail8();
|
|
@@ -2029,7 +2032,7 @@ var AlphaEditTrainingResultContentSchema = z19.object({
|
|
|
2029
2032
|
var AlphaEditTrainingResultSchema = AlphaEditTrainingResultContentSchema.extend({ contentHash: AlphaEditHashSchema });
|
|
2030
2033
|
async function parseAndVerifyAlphaEditTrainingResult(raw, expected) {
|
|
2031
2034
|
const request = AlphaEditTrainingRequestSchema.parse(expected.request);
|
|
2032
|
-
const value = AlphaEditTrainingResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
2035
|
+
const value = AlphaEditTrainingResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2033
2036
|
const manifest = await parseAndVerifyAlphaEditArtifact(value.artifact.manifest, expected);
|
|
2034
2037
|
const metadata = value.artifact.files.find((file2) => file2.path === "manifest.json");
|
|
2035
2038
|
const patch = value.artifact.files.find((file2) => file2.path === "patch.safetensors");
|
|
@@ -2037,7 +2040,7 @@ async function parseAndVerifyAlphaEditTrainingResult(raw, expected) {
|
|
|
2037
2040
|
const comparison = value.comparisons, reload = comparison.reload;
|
|
2038
2041
|
const contextCount = request.config.contextTemplateGroups.reduce((sum, group) => sum + group.length, 0);
|
|
2039
2042
|
const equivalent = reload.baseWeightsHash === request.model.weightsHash && reload.editedWeightsHash === value.editedWeightsHashAfter && reload.untouchedWeightsHash === value.untouchedWeightsHashAfter && reload.maximumAbsoluteTargetNllDifference <= reload.absoluteTolerance && reload.maximumAbsoluteLogProbabilityDifference <= reload.absoluteTolerance && reload.maximumNextTokenKl <= reload.absoluteTolerance;
|
|
2040
|
-
if (
|
|
2043
|
+
if (contentHash2 !== await canonicalSha256(content) || value.inputHash !== await canonicalSha256(request) || value.modelHash !== await canonicalSha256(request.model) || value.runtimeHash !== expected.runtimeHash || value.dataHash !== await canonicalSha256(request.data) || value.untouchedWeightsHashBefore !== value.untouchedWeightsHashAfter || value.targetLosses.length !== value.editsProcessed || new Set(value.targetLosses.map((row) => row.id)).size !== value.editsProcessed || value.latentOptimizerSteps !== value.targetLosses.reduce((sum, row) => sum + row.optimizerSteps, 0) || value.targetLosses.some((row) => row.optimizerSteps > request.training.maxSteps) || comparison.startingState !== (request.parentArtifact ? "parent" : "base") || comparison.edits.length !== value.editsProcessed || canonicalJson(comparison.edits.map((row) => row.id)) !== canonicalJson(value.targetLosses.map((row) => row.id)) || comparison.edits.some((row) => row.contextCount !== contextCount || row.targetTokens % contextCount !== 0 || row.targetTokens > contextCount * (request.training.maxSequenceLength - 1) || Math.abs(row.afterMeanTargetNll - row.reloadedMeanTargetNll) > reload.maximumAbsoluteTargetNllDifference + 1e-12) || comparison.preservation.examples !== comparison.preservation.comparedPositions || comparison.preservation.meanNextTokenKl > comparison.preservation.maximumNextTokenKl + 1e-12 || reload.comparedTargetTokens !== comparison.edits.reduce((sum, row) => sum + row.targetTokens, 0) || reload.comparedPreservationPositions !== comparison.preservation.comparedPositions || reload.meanNextTokenKl > reload.maximumNextTokenKl + 1e-12 || reload.equivalent !== equivalent || value.forwardTokenWork < 3 * (reload.comparedTargetTokens + reload.comparedPreservationPositions) || value.forwardTokenWork > request.training.maxForwardTokenWork || value.durationMs > request.training.maxDurationSeconds * 1e3 || canonicalJson(value.layerEvidence.map((row) => row.layer)) !== canonicalJson(request.config.layers) || value.layerEvidence.some((row) => row.sequentialKeyCount !== value.editsProcessed) || value.artifact.contentHash !== manifest.contentHash || !metadata || !patch || value.artifact.files.length !== request.config.layers.length + 2 || new Set(value.artifact.files.map((file2) => file2.path)).size !== value.artifact.files.length || metadata.sha256 !== await canonicalSha256(manifest) || metadata.sizeBytes !== new TextEncoder().encode(canonicalJson(manifest)).byteLength || metadata.sizeBytes > 262144 || patch.sha256 !== manifest.payloads.patch.sha256 || patch.sizeBytes !== manifest.payloads.patch.sizeBytes || payloads.some((payload) => !value.artifact.files.some((file2) => file2.path === payload.path && file2.sha256 === payload.sha256 && file2.sizeBytes === payload.sizeBytes)) || value.artifact.files.some((file2) => file2.artifactId !== value.artifact.id) || value.artifact.files.reduce((sum, file2) => sum + file2.sizeBytes, 0) > request.training.maxCheckpointBytes)
|
|
2041
2044
|
throw new OpenPondProtocolError("alphaedit_result_mismatch", "The AlphaEdit result differs from its matrix patch, observed work or committed custody.");
|
|
2042
2045
|
return value;
|
|
2043
2046
|
}
|
|
@@ -2212,9 +2215,9 @@ function fail() {
|
|
|
2212
2215
|
}
|
|
2213
2216
|
var close = (a, b) => Math.abs(a - b) <= 1e-6 * Math.max(1, Math.abs(a), Math.abs(b));
|
|
2214
2217
|
async function parseAndVerifyNeuronTrainingSelection(raw, request) {
|
|
2215
|
-
const value = NeuronTrainingSelectionResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
2218
|
+
const value = NeuronTrainingSelectionResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2216
2219
|
const coordinates = value.entries.map(({ layer, neuron }) => ({ layer, neuron }));
|
|
2217
|
-
if (
|
|
2220
|
+
if (contentHash2 !== await canonicalSha256(content) || value.modelHash !== await canonicalSha256(request.model) || value.dataHash !== await canonicalSha256(request.data) || value.selectionConfigHash !== await canonicalSha256(request.selection) || value.entries.length !== request.selection.count || value.eligibleCount < value.entries.length || new Set(value.entries.map((row) => `${row.layer}:${row.neuron}`)).size !== value.entries.length || new Set(value.targetExampleIds).size !== value.targetExampleIds.length || value.targetExampleIds.length > request.selection.gradientExamples || value.source !== (request.selection.explicitCoordinates ? "explicit" : "automatic") || request.selection.explicitCoordinates && canonicalJson(coordinates) !== canonicalJson(request.selection.explicitCoordinates)) fail();
|
|
2218
2221
|
if (value.source === "automatic" && value.entries.some((row, index) => {
|
|
2219
2222
|
const previous = value.entries[index - 1];
|
|
2220
2223
|
return previous && (row.score > previous.score || row.score === previous.score && (row.layer < previous.layer || row.layer === previous.layer && row.neuron < previous.neuron));
|
|
@@ -2264,10 +2267,10 @@ var NeuronTrainingArtifactContentSchema = z21.object({
|
|
|
2264
2267
|
var NeuronTrainingArtifactSchema = NeuronTrainingArtifactContentSchema.extend({ contentHash: Hash17 });
|
|
2265
2268
|
async function parseAndVerifyNeuronTrainingArtifact(raw, expected) {
|
|
2266
2269
|
assertBoundedTaskJson5(raw, 262144);
|
|
2267
|
-
const value = NeuronTrainingArtifactSchema.parse(raw), { contentHash, ...content } = value;
|
|
2270
|
+
const value = NeuronTrainingArtifactSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2268
2271
|
const request = await parseAndVerifyNeuronTrainingRequest(expected.request);
|
|
2269
2272
|
await parseAndVerifyNeuronTrainingSelection(value.selection, request);
|
|
2270
|
-
if (
|
|
2273
|
+
if (contentHash2 !== await canonicalSha256(content) || canonicalJson(value.pins.baseModel) !== canonicalJson(request.model) || canonicalJson(value.pins.data) !== canonicalJson(request.data) || value.pins.inputHash !== await canonicalSha256(request) || value.pins.dataHash !== await canonicalSha256(request.data) || value.pins.selectionConfigHash !== await canonicalSha256(request.selection) || value.pins.trainingConfigHash !== await canonicalSha256(request.training) || value.pins.runtimeHash !== expected.runtimeHash || canonicalJson(value.payload.tensors) !== canonicalJson(neuronTrainingPatchTensorInventory(value.selection)) || value.payload.sizeBytes > request.training.maxCheckpointBytes) fail();
|
|
2271
2274
|
return value;
|
|
2272
2275
|
}
|
|
2273
2276
|
|
|
@@ -2324,10 +2327,10 @@ var NeuronTrainingResultSchema = NeuronTrainingResultContentSchema.extend({ cont
|
|
|
2324
2327
|
async function parseAndVerifyNeuronTrainingResult(raw, expected) {
|
|
2325
2328
|
assertBoundedTaskJson6(raw, 1048576);
|
|
2326
2329
|
const request = await parseAndVerifyNeuronTrainingRequest(expected.request);
|
|
2327
|
-
const value = NeuronTrainingResultSchema.parse(raw), { contentHash, ...content } = value;
|
|
2330
|
+
const value = NeuronTrainingResultSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2328
2331
|
const manifest = await parseAndVerifyNeuronTrainingArtifact(value.artifact.manifest, { request, runtimeHash: expected.runtimeHash });
|
|
2329
2332
|
const tensor = value.artifact.files.find((row) => row.path === "patch.safetensors"), metadata = value.artifact.files.find((row) => row.path === "manifest.json");
|
|
2330
|
-
if (
|
|
2333
|
+
if (contentHash2 !== await canonicalSha256(content) || value.inputHash !== await canonicalSha256(request) || value.modelHash !== await canonicalSha256(request.model) || value.dataHash !== await canonicalSha256(request.data) || value.runtimeHash !== expected.runtimeHash || value.preparedRowsHash !== value.selection.preparedRowsHash || canonicalJson(value.selection) !== canonicalJson(manifest.selection) || value.artifact.contentHash !== manifest.contentHash || value.baseWeightsHashBefore !== request.model.weightsHash || value.baseWeightsHashAfter !== value.baseWeightsHashBefore || value.trainableParameterCount !== request.selection.count * (request.model.hiddenSize + 1) || value.optimizerSteps !== request.training.maxSteps || value.examplesProcessed !== value.optimizerSteps * request.training.gradientAccumulationSteps || value.durationMs > request.training.maxDurationSeconds * 1e3 || value.forwardTokenWork > request.training.maximumForwardTokenWork || value.forwardTokenWork !== Object.values(value.work).reduce((sum, work) => sum + work, 0) || value.backwardTokenWork !== value.work.selectionGradient + value.work.training + value.work.preservationEdited || value.targetTokens > value.work.training || value.work.selectionTarget <= 0 || value.work.selectionBackground <= 0 || value.work.selectionGradient !== value.work.selectionTarget || value.work.verification <= 0 || request.training.preservationWeight > 0 !== (value.meanPreservationKl !== null) || value.work.preservationOriginal !== value.work.preservationEdited || request.training.preservationWeight === 0 && (value.preservationTokens !== 0 || value.work.preservationOriginal !== 0) || request.training.preservationWeight > 0 && (value.preservationTokens <= 0 || value.work.preservationOriginal <= 0) || !tensor || !metadata || tensor.sha256 !== manifest.payload.sha256 || tensor.sizeBytes !== manifest.payload.sizeBytes || metadata.sha256 !== await canonicalSha256(manifest) || metadata.sizeBytes !== new TextEncoder().encode(canonicalJson(manifest)).byteLength || value.artifact.files.some((row) => row.artifactId !== value.artifact.id) || value.artifact.files.reduce((sum, row) => sum + row.sizeBytes, 0) > request.training.maxCheckpointBytes)
|
|
2331
2334
|
throw new OpenPondProtocolError("neuron_training_result_mismatch", "The selective neuron result differs from its exact run, measured work, frozen base or committed learned patch.");
|
|
2332
2335
|
return value;
|
|
2333
2336
|
}
|
|
@@ -2499,8 +2502,8 @@ var ModelModificationCapabilitiesSchema = ModelModificationCapabilitiesContentSc
|
|
|
2499
2502
|
async function parseAndVerifyModelModificationCapabilities(raw, rawQuery, actorId) {
|
|
2500
2503
|
const query = ModelModificationCapabilitiesQuerySchema.parse(rawQuery), value = ModelModificationCapabilitiesSchema.parse(raw);
|
|
2501
2504
|
for (const method of value.methods) assertModelModificationValidationLevel(method.execution, method.validationLevel);
|
|
2502
|
-
const { contentHash, ...content } = value;
|
|
2503
|
-
if (canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId ||
|
|
2505
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
2506
|
+
if (canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || contentHash2 !== await canonicalSha256(content))
|
|
2504
2507
|
throw new OpenPondProtocolError("model_modification_capability_mismatch", "Capabilities returned a different model, account or retained observation.");
|
|
2505
2508
|
const checked = Date.parse(value.checkedAt), expiry = Date.parse(value.expiresAt);
|
|
2506
2509
|
if (checked > Date.now() + 3e4 || expiry <= Date.now() || expiry <= checked || expiry - checked > 3e5)
|
|
@@ -2728,8 +2731,8 @@ function fail2() {
|
|
|
2728
2731
|
throw new OpenPondProtocolError("weight_model_version_mismatch", "The saved Model differs from its exact learned weights, source or committed artifact.");
|
|
2729
2732
|
}
|
|
2730
2733
|
async function verifyEnvelope(value, expected) {
|
|
2731
|
-
const { contentHash, ...content } = value;
|
|
2732
|
-
if (
|
|
2734
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
2735
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId !== void 0 && value.teamId !== expected.teamId || expected.modelProjectId !== void 0 && value.modelProjectId !== expected.modelProjectId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || value.baseModel.source !== "managed" || value.baseModel.modelAssetId !== null || value.baseModel.modelId !== value.request.model.modelId || value.baseModel.revision !== value.request.model.revision || !value.baseModel.tokenizerRevision || value.source.inputHash !== await canonicalSha256(value.request) || value.artifact.contentHash !== value.artifact.manifest.contentHash) fail2();
|
|
2733
2736
|
}
|
|
2734
2737
|
async function verifyFiles(artifact, manifest, payloads, maximumBytes) {
|
|
2735
2738
|
const encoded = canonicalJson(manifest);
|
|
@@ -2801,8 +2804,8 @@ var NeuronTrainingResultSaveReceiptContentSchema = z27.object({
|
|
|
2801
2804
|
}).strict();
|
|
2802
2805
|
var NeuronTrainingResultSaveReceiptSchema = NeuronTrainingResultSaveReceiptContentSchema.extend({ contentHash: Hash23 });
|
|
2803
2806
|
async function verifySave(value, request) {
|
|
2804
|
-
const { contentHash, ...content } = value;
|
|
2805
|
-
if (
|
|
2807
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
2808
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== request.teamId || value.model.teamId !== request.teamId || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256(request) || value.version.source.executionId !== request.executionId || value.version.source.resultHash !== request.resultHash || value.version.artifact.contentHash !== request.artifactHash || value.model.name !== request.name || value.model.revision !== request.expectedModelRevision + 1 || request.modelProjectId !== null && value.model.id !== request.modelProjectId || value.version.portableProjectId !== value.model.portableProjectId) fail2();
|
|
2806
2809
|
}
|
|
2807
2810
|
async function parseAndVerifyAlphaEditResultSaveReceipt(raw, input) {
|
|
2808
2811
|
const request = SaveRequest.parse(input), value = AlphaEditResultSaveReceiptSchema.parse(raw);
|
|
@@ -2852,9 +2855,9 @@ var SteeringProfilePublicationContentSchema = z28.object({
|
|
|
2852
2855
|
}).strict();
|
|
2853
2856
|
var SteeringProfilePublicationSchema = SteeringProfilePublicationContentSchema.extend({ contentHash: Hash24 }).strict();
|
|
2854
2857
|
async function parseAndVerifySteeringProfilePublication(raw, expected = {}) {
|
|
2855
|
-
const value = SteeringProfilePublicationSchema.parse(raw), { contentHash, ...content } = value;
|
|
2858
|
+
const value = SteeringProfilePublicationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2856
2859
|
await parseAndVerifyNeuronSteeringProfile(value.profile);
|
|
2857
|
-
if (
|
|
2860
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId && value.teamId !== expected.teamId || expected.ownerUserId && value.ownerUserId !== expected.ownerUserId || expected.id && value.id !== expected.id || value.baseModel.modelId !== value.profile.model.modelId || value.baseModel.revision !== value.profile.model.revision || new Set(value.calibrationEvidence.map((row) => row.promptId)).size !== value.calibrationEvidence.length)
|
|
2858
2861
|
throw new OpenPondProtocolError("steering_publication_mismatch", "The immutable steering profile differs from its exact source or workspace.");
|
|
2859
2862
|
return value;
|
|
2860
2863
|
}
|
|
@@ -2875,9 +2878,9 @@ async function parseAndVerifySavedModelVersion(raw, expected = {}) {
|
|
|
2875
2878
|
if (value.schemaVersion === "openpond.decisionModelVersion.v1") return parseAndVerifyDecisionModelVersion(value, expected);
|
|
2876
2879
|
if (value.schemaVersion === "openpond.alphaEditModelVersion.v1") return parseAndVerifyAlphaEditModelVersion(value, expected);
|
|
2877
2880
|
if (value.schemaVersion === "openpond.neuronTrainingModelVersion.v1") return parseAndVerifyNeuronTrainingModelVersion(value, expected);
|
|
2878
|
-
const { contentHash, ...content } = value;
|
|
2881
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
2879
2882
|
await parseAndVerifySteeringProfilePublication(value.publication, expected);
|
|
2880
|
-
if (
|
|
2883
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== value.publication.teamId || expected.teamId && value.teamId !== expected.teamId || expected.modelProjectId && value.modelProjectId !== expected.modelProjectId)
|
|
2881
2884
|
throw new OpenPondProtocolError("saved_model_version_mismatch", "The saved steering Model version differs from its immutable publication.");
|
|
2882
2885
|
return value;
|
|
2883
2886
|
}
|
|
@@ -2890,9 +2893,9 @@ var SteeringProfileRecordContentSchema = z28.object({
|
|
|
2890
2893
|
}).strict();
|
|
2891
2894
|
var SteeringProfileRecordSchema = SteeringProfileRecordContentSchema.extend({ contentHash: Hash24 }).strict();
|
|
2892
2895
|
async function parseAndVerifySteeringProfileRecord(raw, expected = {}) {
|
|
2893
|
-
const value = SteeringProfileRecordSchema.parse(raw), { contentHash, ...content } = value;
|
|
2896
|
+
const value = SteeringProfileRecordSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2894
2897
|
await parseAndVerifySteeringProfilePublication(value.publication, expected);
|
|
2895
|
-
if (
|
|
2898
|
+
if (contentHash2 !== await canonicalSha256(content)) throw new OpenPondProtocolError("steering_profile_record_mismatch", "The retained profile record changed.");
|
|
2896
2899
|
return value;
|
|
2897
2900
|
}
|
|
2898
2901
|
var SteeringProfileSaveRequestSchema = z28.object({
|
|
@@ -2922,10 +2925,10 @@ var SteeringProfileReceiptContentSchema = z28.object({
|
|
|
2922
2925
|
}).strict();
|
|
2923
2926
|
var SteeringProfileReceiptSchema = SteeringProfileReceiptContentSchema.extend({ contentHash: Hash24 }).strict();
|
|
2924
2927
|
async function parseAndVerifySteeringProfileReceipt(raw, request, id) {
|
|
2925
|
-
const value = SteeringProfileReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
2928
|
+
const value = SteeringProfileReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
2926
2929
|
await parseAndVerifySteeringProfileRecord(value.record, { teamId: request.teamId, ownerUserId: value.actorId, id });
|
|
2927
2930
|
const saving = "executionId" in request;
|
|
2928
|
-
if (
|
|
2931
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== request.teamId || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256(saving ? request : { id, request })) throw new OpenPondProtocolError("steering_profile_receipt_mismatch", "Retry the original steering Model command.");
|
|
2929
2932
|
if (saving) {
|
|
2930
2933
|
const publication = value.record.publication;
|
|
2931
2934
|
if (!value.model || !value.version || publication.source.executionId !== request.executionId || publication.source.variantId !== request.variantId || publication.source.resultHash !== request.resultHash || publication.profile.contentHash !== request.profileHash || publication.name !== request.name || value.model.name !== request.name || request.modelProjectId && value.model.id !== request.modelProjectId || value.model.revision !== request.expectedModelRevision + 1) throw new OpenPondProtocolError("steering_profile_receipt_mismatch", "The saved Model differs from the selected result variant.");
|
|
@@ -2990,8 +2993,8 @@ function createSteeringProfileClient(request) {
|
|
|
2990
2993
|
const query = Object.fromEntries(Object.entries(SteeringProfileListQuerySchema.parse(raw)).filter(([, value]) => value !== void 0));
|
|
2991
2994
|
const params5 = new URLSearchParams({ teamId: Id18.parse(teamId) });
|
|
2992
2995
|
for (const [key, value] of Object.entries(query)) if (value !== void 0) params5.set(key, String(value));
|
|
2993
|
-
const page = SteeringProfilePageSchema.parse(await request(`/v1/training/steering-profiles?${params5}`)), { contentHash, ...content } = page;
|
|
2994
|
-
if (page.teamId !== teamId || canonicalJson(page.query) !== canonicalJson(query) ||
|
|
2996
|
+
const page = SteeringProfilePageSchema.parse(await request(`/v1/training/steering-profiles?${params5}`)), { contentHash: contentHash2, ...content } = page;
|
|
2997
|
+
if (page.teamId !== teamId || canonicalJson(page.query) !== canonicalJson(query) || contentHash2 !== await canonicalSha256(content) || page.items.length > query.limit || new Set(page.items.map((row) => row.id)).size !== page.items.length || page.nextCursor !== null && (page.items.length !== query.limit || page.nextCursor === query.cursor))
|
|
2995
2998
|
throw new OpenPondProtocolError("steering_profile_page_mismatch", "Refresh this profile history.");
|
|
2996
2999
|
for (const [index, item] of page.items.entries()) {
|
|
2997
3000
|
if (item.teamId !== teamId || item.ownerUserId !== page.ownerUserId || query.projectId && item.projectId !== query.projectId || query.modelProjectId && item.modelProjectId !== query.modelProjectId || item.archived !== query.archived || index && page.items[index - 1].id >= item.id) throw new OpenPondProtocolError("steering_profile_page_mismatch", "The profile list scope changed.");
|
|
@@ -3007,10 +3010,10 @@ function createSteeringProfileClient(request) {
|
|
|
3007
3010
|
}
|
|
3008
3011
|
|
|
3009
3012
|
// src/experiment-draft-storage.ts
|
|
3010
|
-
import { z as
|
|
3013
|
+
import { z as z37 } from "zod";
|
|
3011
3014
|
|
|
3012
3015
|
// src/training-experiment-setup.ts
|
|
3013
|
-
import { z as
|
|
3016
|
+
import { z as z36 } from "zod";
|
|
3014
3017
|
|
|
3015
3018
|
// src/training-preparations.ts
|
|
3016
3019
|
import { z as z29 } from "zod";
|
|
@@ -3087,7 +3090,7 @@ var TrainingPreparationPageSchema = z29.object({
|
|
|
3087
3090
|
}).strict();
|
|
3088
3091
|
async function parseAndVerifyTrainingPreparationReceipt(value) {
|
|
3089
3092
|
const receipt2 = TrainingPreparationReceiptSchema.parse(value);
|
|
3090
|
-
const { contentHash, ...plan } = receipt2.plan;
|
|
3093
|
+
const { contentHash: contentHash2, ...plan } = receipt2.plan;
|
|
3091
3094
|
const usageFunding = plan.request.usageFunding;
|
|
3092
3095
|
if (Boolean(usageFunding) !== Boolean(plan.usageQuote))
|
|
3093
3096
|
throw new OpenPondProtocolError("training_usage_quote_mismatch", "Retain the reviewed complete Job price before starting.");
|
|
@@ -3099,7 +3102,7 @@ async function parseAndVerifyTrainingPreparationReceipt(value) {
|
|
|
3099
3102
|
submissionHash: plan.submissionHash,
|
|
3100
3103
|
customerCapUsd: usageFunding.customerCapUsd
|
|
3101
3104
|
});
|
|
3102
|
-
if (await canonicalSha256(plan) !==
|
|
3105
|
+
if (await canonicalSha256(plan) !== contentHash2 || await canonicalSha256(plan.request) !== plan.requestHash || plan.source.modelProject.id !== plan.request.configuration.id || await canonicalSha256(plan.source.origin ?? null) !== await canonicalSha256(plan.request.origin ?? null)) {
|
|
3103
3106
|
throw new OpenPondProtocolError(
|
|
3104
3107
|
"training_preparation_mismatch",
|
|
3105
3108
|
"The prepared training inputs changed."
|
|
@@ -3397,6 +3400,25 @@ var EngramExperimentFormDraftSchema = z33.object({
|
|
|
3397
3400
|
startingModule: SavedEngramExperimentSourceSchema.optional()
|
|
3398
3401
|
}).strict();
|
|
3399
3402
|
|
|
3403
|
+
// src/training-experiment-setup.ts
|
|
3404
|
+
import { LearningRevisionRefSchema as LearningRevisionRefSchema2 } from "@openpond/evals/learning";
|
|
3405
|
+
|
|
3406
|
+
// src/training-experiment-learning-intent.ts
|
|
3407
|
+
import { z as z34 } from "zod";
|
|
3408
|
+
import { LearningRevisionRefSchema } from "@openpond/evals/learning";
|
|
3409
|
+
var TrainingExperimentLearningIntentSchema = z34.object({
|
|
3410
|
+
enabled: z34.boolean(),
|
|
3411
|
+
/** Applies only after an accepted compatible GRPO checkpoint exists. */
|
|
3412
|
+
continuationAdapterMode: z34.enum(["shared", "residual_append", "sequential_merge"]).optional(),
|
|
3413
|
+
graders: z34.array(LearningRevisionRefSchema).max(100).optional(),
|
|
3414
|
+
mode: z34.enum(["nightly", "approved_count"]),
|
|
3415
|
+
minimumTasks: z34.string().max(100),
|
|
3416
|
+
localTime: z34.string().max(100),
|
|
3417
|
+
timeZone: z34.string().max(200),
|
|
3418
|
+
maximumSpendUsd: z34.string().max(100),
|
|
3419
|
+
maximumDailySpendUsd: z34.string().max(100)
|
|
3420
|
+
}).strict();
|
|
3421
|
+
|
|
3400
3422
|
// src/steering-experiment-source-verification.ts
|
|
3401
3423
|
function savedSteeringExperimentSource(version) {
|
|
3402
3424
|
return SavedSteeringExperimentSourceSchema.parse({
|
|
@@ -3415,35 +3437,35 @@ async function verifySavedSteeringExperimentSource(raw, resolved, expected = {})
|
|
|
3415
3437
|
}
|
|
3416
3438
|
|
|
3417
3439
|
// src/experiment-starting-model.ts
|
|
3418
|
-
import { z as
|
|
3440
|
+
import { z as z35 } from "zod";
|
|
3419
3441
|
var fields = {
|
|
3420
|
-
label:
|
|
3421
|
-
inferenceModelId:
|
|
3442
|
+
label: z35.string().trim().min(1).max(500),
|
|
3443
|
+
inferenceModelId: z35.string().trim().min(1).max(500).nullable(),
|
|
3422
3444
|
baseModel: ModelProjectBaseModelSchema.nullable()
|
|
3423
3445
|
};
|
|
3424
|
-
var ExperimentStartingModelSchema =
|
|
3425
|
-
|
|
3446
|
+
var ExperimentStartingModelSchema = z35.discriminatedUnion("source", [
|
|
3447
|
+
z35.object({ ...fields, source: z35.literal("inference") }).strict().refine(
|
|
3426
3448
|
(value) => Boolean(value.inferenceModelId),
|
|
3427
3449
|
{ message: "Retain the selected model's original inference identity." }
|
|
3428
3450
|
),
|
|
3429
|
-
|
|
3451
|
+
z35.object({ ...fields, source: z35.literal("managed") }).strict().refine(
|
|
3430
3452
|
(value) => Boolean(value.baseModel),
|
|
3431
3453
|
{ message: "Retain the selected model's original managed identity." }
|
|
3432
3454
|
),
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3455
|
+
z35.object({ ...fields, source: z35.literal("steering"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, steering: SavedSteeringExperimentSourceSchema }).strict(),
|
|
3456
|
+
z35.object({ ...fields, source: z35.literal("engram"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, engram: SavedEngramExperimentSourceSchema }).strict(),
|
|
3457
|
+
z35.object({ ...fields, source: z35.literal("alphaedit"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, alphaedit: SavedAlphaEditExperimentSourceSchema }).strict(),
|
|
3458
|
+
z35.object({ ...fields, source: z35.literal("neuron_training"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, neuronTraining: SavedNeuronTrainingExperimentSourceSchema }).strict(),
|
|
3459
|
+
z35.object({ ...fields, source: z35.literal("decision"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, decision: SavedDecisionExperimentSourceSchema }).strict().superRefine((value, context) => {
|
|
3438
3460
|
if (canonicalJson(value.baseModel) !== canonicalJson(decisionSourcePreference()))
|
|
3439
3461
|
context.addIssue({ code: "custom", path: ["baseModel"], message: "Retain the saved decision Model's exact adapter release and its own tokenizer." });
|
|
3440
3462
|
}),
|
|
3441
|
-
|
|
3463
|
+
z35.object({
|
|
3442
3464
|
...fields,
|
|
3443
|
-
source:
|
|
3444
|
-
inferenceModelId:
|
|
3465
|
+
source: z35.literal("trained"),
|
|
3466
|
+
inferenceModelId: z35.null(),
|
|
3445
3467
|
baseModel: ModelProjectBaseModelSchema,
|
|
3446
|
-
trainedVersion:
|
|
3468
|
+
trainedVersion: z35.lazy(() => TrainingModelVersionSchema)
|
|
3447
3469
|
}).strict().superRefine((value, context) => {
|
|
3448
3470
|
if (canonicalJson(value.baseModel) !== canonicalJson(value.trainedVersion.request.baseModel))
|
|
3449
3471
|
context.addIssue({ code: "custom", path: ["baseModel"], message: "Retain the trained version's exact original base." });
|
|
@@ -3481,12 +3503,13 @@ async function parseAndVerifyExperimentStartingModel(raw, expected = {}) {
|
|
|
3481
3503
|
}
|
|
3482
3504
|
|
|
3483
3505
|
// src/training-experiment-setup.ts
|
|
3484
|
-
var ExperimentOperationTypeSchema =
|
|
3506
|
+
var ExperimentOperationTypeSchema = z36.enum(["evaluate", "sft", "grpo", "neuron_steering", "inspect_activations", "engram_adapter", "decision_model", "alphaedit", "selective_neuron_training"]);
|
|
3485
3507
|
function experimentOperationLabel(type) {
|
|
3486
|
-
return { evaluate: "Evaluate", sft: "SFT
|
|
3508
|
+
return { evaluate: "Evaluate", sft: "SFT", grpo: "RL", neuron_steering: "Neuron steering", inspect_activations: "Inspect activations", engram_adapter: "Engram memory", decision_model: "Decision model", alphaedit: "AlphaEdit", selective_neuron_training: "Neuron training" }[type];
|
|
3487
3509
|
}
|
|
3488
3510
|
var TrainingExperimentSetupRequestSchema = TrainingPreparationRequestSchema.omit({ configuration: true, origin: true }).extend({
|
|
3489
|
-
schemaVersion:
|
|
3511
|
+
schemaVersion: z36.literal("openpond.trainingExperimentSetupRequest.v1"),
|
|
3512
|
+
configuration: TrainingPreparationRequestSchema.shape.configuration.optional(),
|
|
3490
3513
|
baseModel: ModelProjectBaseModelSchema,
|
|
3491
3514
|
settings: ModelProjectTrainingSetupSchema.omit({ baseModel: true })
|
|
3492
3515
|
}).strict().superRefine((value, context) => {
|
|
@@ -3499,10 +3522,10 @@ var TrainingExperimentSetupRequestSchema = TrainingPreparationRequestSchema.omit
|
|
|
3499
3522
|
if (value.settings.method !== value.settings.recipe?.method)
|
|
3500
3523
|
context.addIssue({ code: "custom", path: ["settings", "method"], message: "The method must match its recipe." });
|
|
3501
3524
|
});
|
|
3502
|
-
var TrainingExperimentSetupReceiptSchema =
|
|
3503
|
-
schemaVersion:
|
|
3525
|
+
var TrainingExperimentSetupReceiptSchema = z36.object({
|
|
3526
|
+
schemaVersion: z36.literal("openpond.trainingExperimentSetupReceipt.v1"),
|
|
3504
3527
|
request: TrainingExperimentSetupRequestSchema,
|
|
3505
|
-
requestHash:
|
|
3528
|
+
requestHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3506
3529
|
preparation: TrainingPreparationReceiptSchema
|
|
3507
3530
|
}).strict();
|
|
3508
3531
|
async function trainingExperimentConfigurationIdentity(input, creatorUserId) {
|
|
@@ -3511,10 +3534,10 @@ async function trainingExperimentConfigurationIdentity(input, creatorUserId) {
|
|
|
3511
3534
|
async function parseAndVerifyTrainingExperimentSetupReceipt(raw) {
|
|
3512
3535
|
const result = TrainingExperimentSetupReceiptSchema.parse(raw);
|
|
3513
3536
|
const preparation = await parseAndVerifyTrainingPreparationReceipt(result.preparation);
|
|
3514
|
-
const { schemaVersion: _schema, baseModel: _base, settings: _settings, ...run } = result.request;
|
|
3537
|
+
const { schemaVersion: _schema, baseModel: _base, settings: _settings, configuration: selectedConfiguration, ...run } = result.request;
|
|
3515
3538
|
const { schemaVersion: _preparedSchema, configuration, ...preparedRun } = preparation.plan.request;
|
|
3516
3539
|
const portableId = await trainingExperimentConfigurationIdentity(result.request, preparation.plan.creatorUserId);
|
|
3517
|
-
if (result.requestHash !== await canonicalSha256(result.request) || await canonicalSha256(run) !== await canonicalSha256(preparedRun) || preparation.plan.source.modelProject.portableProjectId !== portableId || preparation.plan.source.modelProject.revision !== configuration.expectedRevision || preparation.plan.source.modelProject.contentHash !== configuration.expectedEtag) throw new OpenPondProtocolError("training_experiment_setup_mismatch", "The prepared experiment does not match its reviewed draft.");
|
|
3540
|
+
if (result.requestHash !== await canonicalSha256(result.request) || await canonicalSha256(run) !== await canonicalSha256(preparedRun) || (selectedConfiguration ? configuration.id !== selectedConfiguration.id || configuration.expectedRevision !== selectedConfiguration.expectedRevision || configuration.expectedEtag !== selectedConfiguration.expectedEtag : preparation.plan.source.modelProject.portableProjectId !== portableId) || preparation.plan.source.modelProject.revision !== configuration.expectedRevision || preparation.plan.source.modelProject.contentHash !== configuration.expectedEtag || preparation.plan.source.modelProject.id !== configuration.id) throw new OpenPondProtocolError("training_experiment_setup_mismatch", "The prepared experiment does not match its reviewed draft.");
|
|
3518
3541
|
return { ...result, preparation };
|
|
3519
3542
|
}
|
|
3520
3543
|
function createTrainingExperimentSetupClient(request) {
|
|
@@ -3531,42 +3554,49 @@ function createTrainingExperimentSetupClient(request) {
|
|
|
3531
3554
|
}
|
|
3532
3555
|
};
|
|
3533
3556
|
}
|
|
3534
|
-
var TrainingExperimentInputsPageSchema =
|
|
3535
|
-
schemaVersion:
|
|
3536
|
-
teamId:
|
|
3537
|
-
actorId:
|
|
3538
|
-
projectId:
|
|
3539
|
-
models:
|
|
3540
|
-
methods:
|
|
3557
|
+
var TrainingExperimentInputsPageSchema = z36.object({
|
|
3558
|
+
schemaVersion: z36.literal("openpond.trainingExperimentInputsPage.v1"),
|
|
3559
|
+
teamId: z36.string().min(1).max(500),
|
|
3560
|
+
actorId: z36.string().min(1).max(500),
|
|
3561
|
+
projectId: z36.string().min(1).max(500).nullable(),
|
|
3562
|
+
models: z36.array(ModelProjectBaseModelCandidateSchema).max(1e3),
|
|
3563
|
+
methods: z36.array(z36.string().min(1).max(200)).max(100),
|
|
3541
3564
|
billingModes: TrainingBillingModesSchema.optional(),
|
|
3542
|
-
batches:
|
|
3565
|
+
batches: z36.array(z36.object({
|
|
3543
3566
|
reference: ModelProjectVersionedRefSchema,
|
|
3544
3567
|
rewardBinding: ModelProjectVersionedRefSchema,
|
|
3545
|
-
purpose:
|
|
3546
|
-
exampleCount:
|
|
3547
|
-
sealedAt:
|
|
3568
|
+
purpose: z36.enum(["supervised_training", "reward_training", "evaluation"]),
|
|
3569
|
+
exampleCount: z36.number().int().positive(),
|
|
3570
|
+
sealedAt: z36.iso.datetime()
|
|
3548
3571
|
}).strict()).max(100),
|
|
3549
|
-
nextCursor:
|
|
3572
|
+
nextCursor: z36.string().min(1).max(500).nullable()
|
|
3550
3573
|
}).strict();
|
|
3551
|
-
var TrainingExperimentFormDraftSchema =
|
|
3574
|
+
var TrainingExperimentFormDraftSchema = z36.object({
|
|
3552
3575
|
baseModel: ModelProjectBaseModelSchema.nullable(),
|
|
3553
3576
|
recipe: ModelProjectRecipeDocumentSchema,
|
|
3554
3577
|
batch: ModelProjectVersionedRefSchema.nullable(),
|
|
3555
3578
|
evaluation: ModelProjectVersionedRefSchema.nullable(),
|
|
3556
|
-
validationSplit:
|
|
3557
|
-
name:
|
|
3558
|
-
budget:
|
|
3559
|
-
customerCapUsd:
|
|
3560
|
-
billingMode:
|
|
3579
|
+
validationSplit: z36.enum(["validation", "frozen_eval"]),
|
|
3580
|
+
name: z36.string().max(500),
|
|
3581
|
+
budget: z36.string().max(100),
|
|
3582
|
+
customerCapUsd: z36.string().max(100).optional(),
|
|
3583
|
+
billingMode: z36.enum(["prepaid_only", "actual_usage"]).optional(),
|
|
3561
3584
|
gpuSelection: TrainingGpuSelectionSchema.optional(),
|
|
3562
3585
|
parent: TrainingPreparationRequestSchema.shape.parent,
|
|
3563
|
-
startingModelLabel:
|
|
3586
|
+
startingModelLabel: z36.string().trim().min(1).max(500).optional(),
|
|
3587
|
+
learningIntent: TrainingExperimentLearningIntentSchema.optional(),
|
|
3588
|
+
learningConfiguration: z36.object({
|
|
3589
|
+
inputHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3590
|
+
trainingInputHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3591
|
+
configuration: HostedModelProjectSummarySchema,
|
|
3592
|
+
policy: LearningRevisionRefSchema2
|
|
3593
|
+
}).strict().optional()
|
|
3564
3594
|
}).strict();
|
|
3565
|
-
var ExperimentDraftSchema =
|
|
3566
|
-
schemaVersion:
|
|
3567
|
-
id:
|
|
3595
|
+
var ExperimentDraftSchema = z36.object({
|
|
3596
|
+
schemaVersion: z36.literal("openpond.experimentDraft.v1"),
|
|
3597
|
+
id: z36.string().trim().min(1).max(240),
|
|
3568
3598
|
operationType: ExperimentOperationTypeSchema,
|
|
3569
|
-
name:
|
|
3599
|
+
name: z36.string().trim().min(1).max(500),
|
|
3570
3600
|
startingModel: ExperimentStartingModelSchema.optional(),
|
|
3571
3601
|
evaluationForm: EvaluationExperimentDraftSchema.optional(),
|
|
3572
3602
|
hostedEvaluationForm: HostedEvaluationExperimentFormDraftSchema.optional(),
|
|
@@ -3576,7 +3606,7 @@ var ExperimentDraftSchema = z35.object({
|
|
|
3576
3606
|
decisionForm: DecisionExperimentFormDraftSchema.optional(),
|
|
3577
3607
|
alphaEditForm: AlphaEditExperimentFormDraftSchema.optional(),
|
|
3578
3608
|
neuronTrainingForm: NeuronTrainingExperimentFormDraftSchema.optional(),
|
|
3579
|
-
training:
|
|
3609
|
+
training: z36.object({
|
|
3580
3610
|
baseModel: TrainingExperimentSetupRequestSchema.shape.baseModel.optional(),
|
|
3581
3611
|
settings: TrainingExperimentSetupRequestSchema.shape.settings.optional(),
|
|
3582
3612
|
batch: TrainingExperimentSetupRequestSchema.shape.batch.optional(),
|
|
@@ -3664,75 +3694,75 @@ async function parseAndVerifyExperimentDraft(raw, expected = {}) {
|
|
|
3664
3694
|
if (draft.startingModel) await parseAndVerifyExperimentStartingModel(draft.startingModel, expected);
|
|
3665
3695
|
return draft;
|
|
3666
3696
|
}
|
|
3667
|
-
var ExperimentDraftUpdateSchema =
|
|
3668
|
-
schemaVersion:
|
|
3669
|
-
operationId:
|
|
3670
|
-
expectedRevision:
|
|
3697
|
+
var ExperimentDraftUpdateSchema = z36.object({
|
|
3698
|
+
schemaVersion: z36.literal("openpond.experimentDraftUpdate.v1"),
|
|
3699
|
+
operationId: z36.string().trim().min(1).max(240),
|
|
3700
|
+
expectedRevision: z36.number().int().positive(),
|
|
3671
3701
|
draft: ExperimentDraftSchema
|
|
3672
3702
|
}).strict();
|
|
3673
3703
|
|
|
3674
3704
|
// src/experiment-draft-storage.ts
|
|
3675
|
-
var Id21 =
|
|
3676
|
-
var StoredExperimentDraftReferenceSchema =
|
|
3705
|
+
var Id21 = z37.string().trim().min(1).max(240);
|
|
3706
|
+
var StoredExperimentDraftReferenceSchema = z37.object({
|
|
3677
3707
|
id: Id21,
|
|
3678
3708
|
teamId: Id21,
|
|
3679
|
-
apiOrigin:
|
|
3709
|
+
apiOrigin: z37.url().max(2e3)
|
|
3680
3710
|
}).strict();
|
|
3681
|
-
var ExperimentDraftRecordSchema =
|
|
3682
|
-
schemaVersion:
|
|
3711
|
+
var ExperimentDraftRecordSchema = z37.object({
|
|
3712
|
+
schemaVersion: z37.literal("openpond.experimentDraftRecord.v1"),
|
|
3683
3713
|
id: Id21,
|
|
3684
3714
|
teamId: Id21,
|
|
3685
3715
|
ownerUserId: Id21,
|
|
3686
3716
|
projectId: Id21.nullable(),
|
|
3687
|
-
revision:
|
|
3688
|
-
status:
|
|
3717
|
+
revision: z37.number().int().positive(),
|
|
3718
|
+
status: z37.enum(["draft", "archived"]),
|
|
3689
3719
|
draft: ExperimentDraftSchema,
|
|
3690
|
-
createdAt:
|
|
3691
|
-
updatedAt:
|
|
3692
|
-
contentHash:
|
|
3720
|
+
createdAt: z37.iso.datetime(),
|
|
3721
|
+
updatedAt: z37.iso.datetime(),
|
|
3722
|
+
contentHash: z37.string().regex(/^[a-f0-9]{64}$/)
|
|
3693
3723
|
}).strict().superRefine((record, context) => {
|
|
3694
3724
|
if (record.id !== record.draft.id)
|
|
3695
3725
|
context.addIssue({ code: "custom", path: ["id"], message: "The stored draft identity does not match its document." });
|
|
3696
3726
|
});
|
|
3697
|
-
var ExperimentDraftSaveSchema =
|
|
3698
|
-
schemaVersion:
|
|
3727
|
+
var ExperimentDraftSaveSchema = z37.object({
|
|
3728
|
+
schemaVersion: z37.literal("openpond.experimentDraftSave.v1"),
|
|
3699
3729
|
teamId: Id21,
|
|
3700
3730
|
operationId: Id21,
|
|
3701
|
-
expectedRevision:
|
|
3731
|
+
expectedRevision: z37.number().int().nonnegative(),
|
|
3702
3732
|
projectId: Id21.nullable().default(null),
|
|
3703
3733
|
draft: ExperimentDraftSchema
|
|
3704
3734
|
}).strict();
|
|
3705
|
-
var ExperimentDraftArchiveSchema =
|
|
3706
|
-
schemaVersion:
|
|
3735
|
+
var ExperimentDraftArchiveSchema = z37.object({
|
|
3736
|
+
schemaVersion: z37.literal("openpond.experimentDraftArchive.v1"),
|
|
3707
3737
|
teamId: Id21,
|
|
3708
3738
|
operationId: Id21,
|
|
3709
|
-
expectedRevision:
|
|
3739
|
+
expectedRevision: z37.number().int().positive()
|
|
3710
3740
|
}).strict();
|
|
3711
|
-
var ExperimentDraftReceiptSchema =
|
|
3712
|
-
schemaVersion:
|
|
3741
|
+
var ExperimentDraftReceiptSchema = z37.object({
|
|
3742
|
+
schemaVersion: z37.literal("openpond.experimentDraftReceipt.v1"),
|
|
3713
3743
|
operationId: Id21,
|
|
3714
|
-
requestHash:
|
|
3744
|
+
requestHash: z37.string().regex(/^[a-f0-9]{64}$/),
|
|
3715
3745
|
record: ExperimentDraftRecordSchema
|
|
3716
3746
|
}).strict();
|
|
3717
|
-
var ExperimentDraftListQuerySchema =
|
|
3747
|
+
var ExperimentDraftListQuerySchema = z37.object({
|
|
3718
3748
|
projectId: Id21.optional(),
|
|
3719
|
-
search:
|
|
3720
|
-
archived:
|
|
3721
|
-
cursor:
|
|
3722
|
-
limit:
|
|
3749
|
+
search: z37.string().trim().max(1e3).optional(),
|
|
3750
|
+
archived: z37.boolean().default(false),
|
|
3751
|
+
cursor: z37.string().min(1).max(2e3).optional(),
|
|
3752
|
+
limit: z37.number().int().min(1).max(100).default(30)
|
|
3723
3753
|
}).strict();
|
|
3724
|
-
var ExperimentDraftPageSchema =
|
|
3725
|
-
schemaVersion:
|
|
3754
|
+
var ExperimentDraftPageSchema = z37.object({
|
|
3755
|
+
schemaVersion: z37.literal("openpond.experimentDraftPage.v1"),
|
|
3726
3756
|
teamId: Id21,
|
|
3727
3757
|
ownerUserId: Id21,
|
|
3728
3758
|
projectId: Id21.nullable(),
|
|
3729
|
-
items:
|
|
3730
|
-
nextCursor:
|
|
3759
|
+
items: z37.array(ExperimentDraftRecordSchema).max(100),
|
|
3760
|
+
nextCursor: z37.string().min(1).max(2e3).nullable()
|
|
3731
3761
|
}).strict();
|
|
3732
3762
|
async function parseAndVerifyExperimentDraftRecord(raw) {
|
|
3733
3763
|
const record = ExperimentDraftRecordSchema.parse(raw);
|
|
3734
|
-
const { contentHash, ...content } = record;
|
|
3735
|
-
if (
|
|
3764
|
+
const { contentHash: contentHash2, ...content } = record;
|
|
3765
|
+
if (contentHash2 !== await canonicalSha256(content))
|
|
3736
3766
|
throw new OpenPondProtocolError("experiment_draft_hash_mismatch", "The saved draft differs from its retained document.");
|
|
3737
3767
|
await parseAndVerifyExperimentDraft(record.draft, { teamId: record.teamId });
|
|
3738
3768
|
return record;
|
|
@@ -3791,21 +3821,21 @@ function createExperimentDraftClient(request) {
|
|
|
3791
3821
|
}
|
|
3792
3822
|
|
|
3793
3823
|
// src/managed-modification-executions.ts
|
|
3794
|
-
import { z as
|
|
3824
|
+
import { z as z39 } from "zod";
|
|
3795
3825
|
|
|
3796
3826
|
// src/managed-modification-compilation.ts
|
|
3797
|
-
import { z as
|
|
3798
|
-
var Id22 =
|
|
3799
|
-
var Hash27 =
|
|
3800
|
-
var ManagedModificationCompileSchema =
|
|
3827
|
+
import { z as z38 } from "zod";
|
|
3828
|
+
var Id22 = z38.string().trim().min(1).max(240);
|
|
3829
|
+
var Hash27 = z38.string().regex(/^[a-f0-9]{64}$/);
|
|
3830
|
+
var ManagedModificationCompileSchema = z38.object({
|
|
3801
3831
|
teamId: Id22,
|
|
3802
3832
|
projectId: Id22.nullable(),
|
|
3803
3833
|
method: ModelModificationMethodSchema,
|
|
3804
3834
|
query: ModelModificationCapabilitiesQuerySchema,
|
|
3805
3835
|
form: ActivationExperimentFormDraftSchema
|
|
3806
3836
|
}).strict();
|
|
3807
|
-
var ManagedModificationCompilationContentSchema =
|
|
3808
|
-
schemaVersion:
|
|
3837
|
+
var ManagedModificationCompilationContentSchema = z38.object({
|
|
3838
|
+
schemaVersion: z38.literal("openpond.managedModificationCompilation.v1"),
|
|
3809
3839
|
teamId: Id22,
|
|
3810
3840
|
actorId: Id22,
|
|
3811
3841
|
projectId: Id22.nullable(),
|
|
@@ -3837,37 +3867,37 @@ function parseManagedModificationCompile(raw) {
|
|
|
3837
3867
|
}
|
|
3838
3868
|
async function parseAndVerifyManagedModificationCompilation(raw, input) {
|
|
3839
3869
|
const command = parseManagedModificationCompile(input), value = ManagedModificationCompilationSchema.parse(raw);
|
|
3840
|
-
const { contentHash, ...content } = value, request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3870
|
+
const { contentHash: contentHash2, ...content } = value, request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3841
3871
|
if (canonicalJson(command.form.startingProfile ?? null) !== canonicalJson(request.startingProfile ? activationStartingProfileSource(request.startingProfile) : null))
|
|
3842
3872
|
throw new OpenPondProtocolError("managed_modification_compilation_mismatch", "The compilation dropped or changed the saved steering source.");
|
|
3843
3873
|
const profiles = request.variants.filter((row) => row.profile !== null).length;
|
|
3844
|
-
if (
|
|
3874
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== command.teamId || value.projectId !== command.projectId || value.method !== command.method || canonicalJson(value.query) !== canonicalJson(command.query) || value.formHash !== await canonicalSha256(command.form) || value.inputHash !== await canonicalSha256(request) || request.model.modelId !== command.query.modelId || request.model.revision !== command.query.revision || (command.method === "inspect_activations" ? profiles > 0 : profiles === 0 || profiles === request.variants.length))
|
|
3845
3875
|
throw new OpenPondProtocolError("managed_modification_compilation_mismatch", "The compilation differs from the exact requested form, model or bounds.");
|
|
3846
3876
|
return value;
|
|
3847
3877
|
}
|
|
3848
3878
|
|
|
3849
3879
|
// src/managed-modification-executions.ts
|
|
3850
|
-
var Id23 =
|
|
3851
|
-
var Hash28 =
|
|
3852
|
-
var ManagedModificationExecutionContentSchema =
|
|
3853
|
-
schemaVersion:
|
|
3880
|
+
var Id23 = z39.string().trim().min(1).max(240);
|
|
3881
|
+
var Hash28 = z39.string().regex(/^[a-f0-9]{64}$/);
|
|
3882
|
+
var ManagedModificationExecutionContentSchema = z39.object({
|
|
3883
|
+
schemaVersion: z39.literal("openpond.managedModificationExecution.v1"),
|
|
3854
3884
|
id: Id23,
|
|
3855
3885
|
teamId: Id23,
|
|
3856
3886
|
ownerUserId: Id23,
|
|
3857
3887
|
projectId: Id23.nullable(),
|
|
3858
|
-
name:
|
|
3888
|
+
name: z39.string().trim().min(1).max(500),
|
|
3859
3889
|
method: ModelModificationMethodSchema,
|
|
3860
|
-
phase:
|
|
3861
|
-
revision:
|
|
3890
|
+
phase: z39.enum(["prepared", "queued", "dispatching", "stopping", "cancelled", "completed", "failed"]),
|
|
3891
|
+
revision: z39.number().int().positive(),
|
|
3862
3892
|
sourceContentHash: Hash28,
|
|
3863
|
-
plan:
|
|
3893
|
+
plan: z39.object({
|
|
3864
3894
|
contentHash: Hash28,
|
|
3865
3895
|
inputHash: Hash28,
|
|
3866
3896
|
runtimeHash: Hash28,
|
|
3867
|
-
maximumSpendUsd:
|
|
3897
|
+
maximumSpendUsd: z39.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48).nullable(),
|
|
3868
3898
|
computePrice: ManagedModificationPriceSchema.optional(),
|
|
3869
|
-
createdAt:
|
|
3870
|
-
expiresAt:
|
|
3899
|
+
createdAt: z39.iso.datetime(),
|
|
3900
|
+
expiresAt: z39.iso.datetime()
|
|
3871
3901
|
}).strict().superRefine((plan, ctx) => {
|
|
3872
3902
|
try {
|
|
3873
3903
|
assertManagedModificationPricing(plan);
|
|
@@ -3878,58 +3908,58 @@ var ManagedModificationExecutionContentSchema = z38.object({
|
|
|
3878
3908
|
request: ActivationReferenceRequestSchema,
|
|
3879
3909
|
sourceForm: ActivationExperimentFormDraftSchema.optional(),
|
|
3880
3910
|
result: ActivationReferenceResultSchema.nullable(),
|
|
3881
|
-
resultRecordedAt:
|
|
3882
|
-
updatedAt:
|
|
3911
|
+
resultRecordedAt: z39.iso.datetime().nullable(),
|
|
3912
|
+
updatedAt: z39.iso.datetime()
|
|
3883
3913
|
}).strict();
|
|
3884
3914
|
var ManagedModificationExecutionSchema = ManagedModificationExecutionContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3885
|
-
var Spend =
|
|
3886
|
-
var ManagedModificationPrepareSchema =
|
|
3915
|
+
var Spend = z39.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
3916
|
+
var ManagedModificationPrepareSchema = z39.object({
|
|
3887
3917
|
teamId: Id23,
|
|
3888
3918
|
operationId: Id23,
|
|
3889
3919
|
projectId: Id23.nullable(),
|
|
3890
|
-
name:
|
|
3920
|
+
name: z39.string().trim().min(1).max(500),
|
|
3891
3921
|
method: ModelModificationMethodSchema,
|
|
3892
3922
|
query: ModelModificationCapabilitiesQuerySchema,
|
|
3893
3923
|
request: ActivationReferenceRequestSchema,
|
|
3894
3924
|
maximumSpendUsd: Spend.nullish(),
|
|
3895
3925
|
sourceForm: ActivationExperimentFormDraftSchema.optional()
|
|
3896
3926
|
}).strict();
|
|
3897
|
-
var control = { teamId: Id23, id: Id23, operationId: Id23, expectedRevision:
|
|
3898
|
-
var ManagedModificationStartSchema =
|
|
3899
|
-
var ManagedModificationCancelSchema =
|
|
3927
|
+
var control = { teamId: Id23, id: Id23, operationId: Id23, expectedRevision: z39.number().int().positive(), planHash: Hash28 };
|
|
3928
|
+
var ManagedModificationStartSchema = z39.object({ ...control, action: z39.literal("start"), approvedMaximumSpendUsd: Spend.nullable(), approvedPriceHash: Hash28.optional() }).strict();
|
|
3929
|
+
var ManagedModificationCancelSchema = z39.object({ ...control, action: z39.literal("cancel") }).strict();
|
|
3900
3930
|
var ManagedModificationExecutionMetadataSchema = ManagedModificationExecutionContentSchema.omit({ schemaVersion: true, request: true, sourceForm: true, result: true, resultRecordedAt: true });
|
|
3901
|
-
var ManagedModificationExecutionReceiptContentSchema =
|
|
3902
|
-
schemaVersion:
|
|
3931
|
+
var ManagedModificationExecutionReceiptContentSchema = z39.object({
|
|
3932
|
+
schemaVersion: z39.literal("openpond.managedModificationExecutionReceipt.v1"),
|
|
3903
3933
|
operationId: Id23,
|
|
3904
3934
|
requestHash: Hash28,
|
|
3905
3935
|
execution: ManagedModificationExecutionMetadataSchema
|
|
3906
3936
|
}).strict();
|
|
3907
3937
|
var ManagedModificationExecutionReceiptSchema = ManagedModificationExecutionReceiptContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3908
|
-
var ManagedModificationExecutionListQuerySchema =
|
|
3938
|
+
var ManagedModificationExecutionListQuerySchema = z39.object({
|
|
3909
3939
|
id: Id23.optional(),
|
|
3910
3940
|
projectId: Id23.optional(),
|
|
3911
3941
|
method: ModelModificationMethodSchema.optional(),
|
|
3912
3942
|
phase: ManagedModificationExecutionContentSchema.shape.phase.optional(),
|
|
3913
|
-
limit:
|
|
3914
|
-
cursor:
|
|
3943
|
+
limit: z39.number().int().min(1).max(100).default(25),
|
|
3944
|
+
cursor: z39.string().min(1).max(2048).optional()
|
|
3915
3945
|
}).strict();
|
|
3916
3946
|
var ManagedModificationExecutionSummarySchema = ManagedModificationExecutionMetadataSchema.extend({
|
|
3917
3947
|
model: ActivationReferenceRequestSchema.shape.model
|
|
3918
3948
|
}).strict();
|
|
3919
|
-
var ManagedModificationExecutionPageContentSchema =
|
|
3920
|
-
schemaVersion:
|
|
3949
|
+
var ManagedModificationExecutionPageContentSchema = z39.object({
|
|
3950
|
+
schemaVersion: z39.literal("openpond.managedModificationExecutionPage.v1"),
|
|
3921
3951
|
teamId: Id23,
|
|
3922
3952
|
ownerUserId: Id23,
|
|
3923
3953
|
query: ManagedModificationExecutionListQuerySchema,
|
|
3924
|
-
items:
|
|
3925
|
-
nextCursor:
|
|
3954
|
+
items: z39.array(ManagedModificationExecutionSummarySchema).max(100),
|
|
3955
|
+
nextCursor: z39.string().min(1).max(2048).nullable()
|
|
3926
3956
|
}).strict();
|
|
3927
3957
|
var ManagedModificationExecutionPageSchema = ManagedModificationExecutionPageContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3928
3958
|
async function parseAndVerifyManagedModificationExecutionPage(raw, expected) {
|
|
3929
|
-
const page = ManagedModificationExecutionPageSchema.parse(raw), { contentHash, ...content } = page;
|
|
3959
|
+
const page = ManagedModificationExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = page;
|
|
3930
3960
|
const query = ManagedModificationExecutionListQuerySchema.parse(expected.query ?? {});
|
|
3931
3961
|
const invalid = () => new OpenPondProtocolError("managed_modification_history_mismatch", "The execution history differs from its requested scope.");
|
|
3932
|
-
if (page.teamId !== expected.teamId || expected.ownerUserId !== void 0 && page.ownerUserId !== expected.ownerUserId || canonicalJson(page.query) !== canonicalJson(query) ||
|
|
3962
|
+
if (page.teamId !== expected.teamId || expected.ownerUserId !== void 0 && page.ownerUserId !== expected.ownerUserId || canonicalJson(page.query) !== canonicalJson(query) || contentHash2 !== await canonicalSha256(content) || page.items.length > query.limit || new Set(page.items.map((item) => item.id)).size !== page.items.length || page.nextCursor !== null && (page.items.length !== query.limit || page.nextCursor === query.cursor)) throw invalid();
|
|
3933
3963
|
for (const [index, item] of page.items.entries()) {
|
|
3934
3964
|
const previous = page.items[index - 1];
|
|
3935
3965
|
assertManagedModificationPricing(item.plan);
|
|
@@ -3966,16 +3996,16 @@ async function parseAndVerifyManagedModificationPrepare(raw) {
|
|
|
3966
3996
|
return value;
|
|
3967
3997
|
}
|
|
3968
3998
|
function parseManagedModificationControl(raw) {
|
|
3969
|
-
const value =
|
|
3999
|
+
const value = z39.discriminatedUnion("action", [ManagedModificationStartSchema, ManagedModificationCancelSchema]).parse(raw);
|
|
3970
4000
|
if (value.action === "start") value.approvedMaximumSpendUsd = canonicalComputeSpendCap(value.approvedMaximumSpendUsd);
|
|
3971
4001
|
return value;
|
|
3972
4002
|
}
|
|
3973
4003
|
async function parseAndVerifyManagedModificationExecutionReceipt(raw, input) {
|
|
3974
|
-
const value = ManagedModificationExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4004
|
+
const value = ManagedModificationExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
3975
4005
|
const command = "action" in input ? parseManagedModificationControl(input) : await parseAndVerifyManagedModificationPrepare(input);
|
|
3976
4006
|
const execution = value.execution, prepare = !("action" in command);
|
|
3977
4007
|
const expectedHash = await canonicalSha256(prepare ? { action: "prepare", command } : command);
|
|
3978
|
-
if (
|
|
4008
|
+
if (contentHash2 !== await canonicalSha256(content) || value.operationId !== command.operationId || value.requestHash !== expectedHash || execution.teamId !== command.teamId || Date.parse(execution.plan.expiresAt) <= Date.parse(execution.plan.createdAt) || execution.plan.maximumSpendUsd !== canonicalComputeSpendCap(execution.plan.maximumSpendUsd))
|
|
3979
4009
|
throw new OpenPondProtocolError("managed_modification_receipt_mismatch", "The receipt differs from the original operation and reviewed execution.");
|
|
3980
4010
|
if (prepare) {
|
|
3981
4011
|
const request = command;
|
|
@@ -3991,12 +4021,12 @@ async function parseAndVerifyManagedModificationExecutionReceipt(raw, input) {
|
|
|
3991
4021
|
}
|
|
3992
4022
|
async function parseAndVerifyManagedModificationExecution(raw, expected) {
|
|
3993
4023
|
const value = ManagedModificationExecutionSchema.parse(raw);
|
|
3994
|
-
const { contentHash, ...content } = value;
|
|
4024
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
3995
4025
|
const request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3996
4026
|
if (value.sourceForm) verifySourceForm(value.sourceForm, request, value.plan.maximumSpendUsd);
|
|
3997
4027
|
if (request.startingProfile && value.method !== "neuron_steering") throw new OpenPondProtocolError("managed_modification_saved_source_unsupported", "Saved steering sources currently require neuron steering.");
|
|
3998
4028
|
const profiles = request.variants.filter((row) => row.profile !== null).length;
|
|
3999
|
-
if (value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId ||
|
|
4029
|
+
if (value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || contentHash2 !== await canonicalSha256(content) || value.plan.inputHash !== await canonicalSha256(request) || (value.method === "inspect_activations" ? profiles > 0 : profiles === 0 || profiles === request.variants.length) || value.plan.maximumSpendUsd !== canonicalComputeSpendCap(value.plan.maximumSpendUsd) || Boolean(value.result) !== Boolean(value.resultRecordedAt) || Date.parse(value.plan.expiresAt) <= Date.parse(value.plan.createdAt))
|
|
4000
4030
|
throw new OpenPondProtocolError("managed_modification_execution_mismatch", "The execution differs from its retained identity, request or capture.");
|
|
4001
4031
|
if (value.result) await parseAndVerifyActivationReferenceResult(value.result, request);
|
|
4002
4032
|
return value;
|
|
@@ -4053,55 +4083,55 @@ function createManagedModificationExecutionClient(request) {
|
|
|
4053
4083
|
}
|
|
4054
4084
|
|
|
4055
4085
|
// src/managed-engram-executions.ts
|
|
4056
|
-
import { z as
|
|
4057
|
-
var Id24 =
|
|
4058
|
-
var Hash29 =
|
|
4059
|
-
var Money2 =
|
|
4060
|
-
var Method =
|
|
4086
|
+
import { z as z40 } from "zod";
|
|
4087
|
+
var Id24 = z40.string().trim().min(1).max(240);
|
|
4088
|
+
var Hash29 = z40.string().regex(/^[a-f0-9]{64}$/);
|
|
4089
|
+
var Money2 = z40.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4090
|
+
var Method = z40.literal("engram_adapter");
|
|
4061
4091
|
var Query = ModelModificationCapabilitiesQuerySchema;
|
|
4062
|
-
var EngramExecutionCapabilityContentSchema =
|
|
4063
|
-
schemaVersion:
|
|
4092
|
+
var EngramExecutionCapabilityContentSchema = z40.object({
|
|
4093
|
+
schemaVersion: z40.literal("openpond.engramExecutionCapability.v1"),
|
|
4064
4094
|
teamId: Id24,
|
|
4065
4095
|
actorId: Id24,
|
|
4066
4096
|
query: Query,
|
|
4067
4097
|
requestHash: Hash29,
|
|
4068
|
-
checkedAt:
|
|
4069
|
-
expiresAt:
|
|
4098
|
+
checkedAt: z40.iso.datetime(),
|
|
4099
|
+
expiresAt: z40.iso.datetime(),
|
|
4070
4100
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4071
|
-
execution:
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
state:
|
|
4101
|
+
execution: z40.discriminatedUnion("state", [
|
|
4102
|
+
z40.object({ state: z40.literal("unavailable"), code: z40.enum(["model_not_supported", "runtime_not_qualified"]), reason: z40.string().min(1).max(1e3) }).strict(),
|
|
4103
|
+
z40.object({
|
|
4104
|
+
state: z40.literal("ready"),
|
|
4075
4105
|
model: NeuronSteeringModelSchema,
|
|
4076
4106
|
config: EngramAdapterConfigSchema,
|
|
4077
|
-
runtime:
|
|
4107
|
+
runtime: z40.object({
|
|
4078
4108
|
id: Id24,
|
|
4079
4109
|
releaseHash: Hash29,
|
|
4080
|
-
imageDigest:
|
|
4081
|
-
requestSchema:
|
|
4082
|
-
evidence:
|
|
4110
|
+
imageDigest: z40.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4111
|
+
requestSchema: z40.literal("openpond.engramTrainingRequest.v1"),
|
|
4112
|
+
evidence: z40.object({ id: Id24, contentHash: Hash29 }).strict()
|
|
4083
4113
|
}).strict(),
|
|
4084
|
-
limits:
|
|
4085
|
-
maximumExamples:
|
|
4086
|
-
maximumDataBytes:
|
|
4087
|
-
maximumSteps:
|
|
4088
|
-
maximumSequenceLength:
|
|
4089
|
-
maximumDurationSeconds:
|
|
4090
|
-
maximumCheckpointBytes:
|
|
4114
|
+
limits: z40.object({
|
|
4115
|
+
maximumExamples: z40.number().int().min(1).max(1e3),
|
|
4116
|
+
maximumDataBytes: z40.number().int().positive().max(8388608),
|
|
4117
|
+
maximumSteps: z40.number().int().min(1).max(128),
|
|
4118
|
+
maximumSequenceLength: z40.number().int().min(2).max(8192),
|
|
4119
|
+
maximumDurationSeconds: z40.number().finite().min(1).max(21600),
|
|
4120
|
+
maximumCheckpointBytes: z40.number().int().positive().max(2147483648)
|
|
4091
4121
|
}).strict()
|
|
4092
4122
|
}).strict()
|
|
4093
4123
|
])
|
|
4094
4124
|
}).strict();
|
|
4095
4125
|
var EngramExecutionCapabilitySchema = EngramExecutionCapabilityContentSchema.extend({ contentHash: Hash29 });
|
|
4096
|
-
var ManagedEngramCompileSchema =
|
|
4126
|
+
var ManagedEngramCompileSchema = z40.object({
|
|
4097
4127
|
teamId: Id24,
|
|
4098
4128
|
projectId: Id24.nullable(),
|
|
4099
4129
|
method: Method,
|
|
4100
4130
|
query: Query,
|
|
4101
4131
|
form: EngramExperimentFormDraftSchema
|
|
4102
4132
|
}).strict();
|
|
4103
|
-
var ManagedEngramCompilationContentSchema =
|
|
4104
|
-
schemaVersion:
|
|
4133
|
+
var ManagedEngramCompilationContentSchema = z40.object({
|
|
4134
|
+
schemaVersion: z40.literal("openpond.managedEngramCompilation.v1"),
|
|
4105
4135
|
teamId: Id24,
|
|
4106
4136
|
actorId: Id24,
|
|
4107
4137
|
projectId: Id24.nullable(),
|
|
@@ -4112,11 +4142,11 @@ var ManagedEngramCompilationContentSchema = z39.object({
|
|
|
4112
4142
|
request: EngramTrainingRequestSchema
|
|
4113
4143
|
}).strict();
|
|
4114
4144
|
var ManagedEngramCompilationSchema = ManagedEngramCompilationContentSchema.extend({ contentHash: Hash29 });
|
|
4115
|
-
var ManagedEngramPrepareSchema =
|
|
4145
|
+
var ManagedEngramPrepareSchema = z40.object({
|
|
4116
4146
|
teamId: Id24,
|
|
4117
4147
|
operationId: Id24,
|
|
4118
4148
|
projectId: Id24.nullable(),
|
|
4119
|
-
name:
|
|
4149
|
+
name: z40.string().trim().min(1).max(500),
|
|
4120
4150
|
method: Method,
|
|
4121
4151
|
query: Query,
|
|
4122
4152
|
request: EngramTrainingRequestSchema,
|
|
@@ -4127,36 +4157,36 @@ var ManagedEngramStartSchema = ManagedModificationStartSchema;
|
|
|
4127
4157
|
var ManagedEngramCancelSchema = ManagedModificationCancelSchema;
|
|
4128
4158
|
var ManagedEngramExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method }).strict();
|
|
4129
4159
|
var ManagedEngramExecutionContentSchema = ManagedEngramExecutionMetadataSchema.extend({
|
|
4130
|
-
schemaVersion:
|
|
4160
|
+
schemaVersion: z40.literal("openpond.managedEngramExecution.v1"),
|
|
4131
4161
|
request: EngramTrainingRequestSchema,
|
|
4132
4162
|
sourceForm: EngramExperimentFormDraftSchema.optional(),
|
|
4133
4163
|
result: EngramTrainingResultSchema.nullable(),
|
|
4134
|
-
resultRecordedAt:
|
|
4164
|
+
resultRecordedAt: z40.iso.datetime().nullable()
|
|
4135
4165
|
}).strict();
|
|
4136
4166
|
var ManagedEngramExecutionSchema = ManagedEngramExecutionContentSchema.extend({ contentHash: Hash29 });
|
|
4137
|
-
var ManagedEngramExecutionReceiptContentSchema =
|
|
4138
|
-
schemaVersion:
|
|
4167
|
+
var ManagedEngramExecutionReceiptContentSchema = z40.object({
|
|
4168
|
+
schemaVersion: z40.literal("openpond.managedEngramExecutionReceipt.v1"),
|
|
4139
4169
|
operationId: Id24,
|
|
4140
4170
|
requestHash: Hash29,
|
|
4141
4171
|
execution: ManagedEngramExecutionMetadataSchema
|
|
4142
4172
|
}).strict();
|
|
4143
4173
|
var ManagedEngramExecutionReceiptSchema = ManagedEngramExecutionReceiptContentSchema.extend({ contentHash: Hash29 });
|
|
4144
|
-
var ManagedEngramExecutionListQuerySchema =
|
|
4174
|
+
var ManagedEngramExecutionListQuerySchema = z40.object({
|
|
4145
4175
|
method: Method.default("engram_adapter"),
|
|
4146
4176
|
id: Id24.optional(),
|
|
4147
4177
|
projectId: Id24.optional(),
|
|
4148
4178
|
phase: ManagedEngramExecutionMetadataSchema.shape.phase.optional(),
|
|
4149
|
-
limit:
|
|
4150
|
-
cursor:
|
|
4179
|
+
limit: z40.number().int().min(1).max(100).default(25),
|
|
4180
|
+
cursor: z40.string().min(1).max(2048).optional()
|
|
4151
4181
|
}).strict();
|
|
4152
4182
|
var ManagedEngramExecutionSummarySchema = ManagedEngramExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4153
|
-
var ManagedEngramExecutionPageContentSchema =
|
|
4154
|
-
schemaVersion:
|
|
4183
|
+
var ManagedEngramExecutionPageContentSchema = z40.object({
|
|
4184
|
+
schemaVersion: z40.literal("openpond.managedEngramExecutionPage.v1"),
|
|
4155
4185
|
teamId: Id24,
|
|
4156
4186
|
ownerUserId: Id24,
|
|
4157
4187
|
query: ManagedEngramExecutionListQuerySchema,
|
|
4158
|
-
items:
|
|
4159
|
-
nextCursor:
|
|
4188
|
+
items: z40.array(ManagedEngramExecutionSummarySchema).max(100),
|
|
4189
|
+
nextCursor: z40.string().min(1).max(2048).nullable()
|
|
4160
4190
|
}).strict();
|
|
4161
4191
|
var ManagedEngramExecutionPageSchema = ManagedEngramExecutionPageContentSchema.extend({ contentHash: Hash29 });
|
|
4162
4192
|
function parseEngramFormTraining(raw) {
|
|
@@ -4189,26 +4219,26 @@ function checkFormQuery(form, query) {
|
|
|
4189
4219
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail3();
|
|
4190
4220
|
}
|
|
4191
4221
|
async function parseAndVerifyEngramExecutionCapability(raw, queryInput, actorId) {
|
|
4192
|
-
const query = Query.parse(queryInput), value = EngramExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4222
|
+
const query = Query.parse(queryInput), value = EngramExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4193
4223
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4194
4224
|
const checked = Date.parse(value.checkedAt), expires = Date.parse(value.expiresAt);
|
|
4195
|
-
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) ||
|
|
4225
|
+
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || contentHash2 !== await canonicalSha256(content) || checked > Date.now() + 3e4 || expires <= Date.now() || expires <= checked || expires - checked > 3e5) fail3();
|
|
4196
4226
|
if (value.execution.state === "ready") checkSource(query, { model: value.execution.model });
|
|
4197
4227
|
return value;
|
|
4198
4228
|
}
|
|
4199
4229
|
async function parseAndVerifyManagedEngramCompilation(raw, input) {
|
|
4200
|
-
const command = ManagedEngramCompileSchema.parse(input), value = ManagedEngramCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4230
|
+
const command = ManagedEngramCompileSchema.parse(input), value = ManagedEngramCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4201
4231
|
const request = await parseAndVerifyEngramTrainingRequest(value.request);
|
|
4202
4232
|
checkSource(command.query, request);
|
|
4203
4233
|
await checkForm(command.form, request);
|
|
4204
4234
|
checkFormQuery(command.form, command.query);
|
|
4205
|
-
if (
|
|
4235
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== command.teamId || command.query.teamId !== command.teamId || value.projectId !== command.projectId || canonicalJson(value.query) !== canonicalJson(command.query) || value.formHash !== await canonicalSha256(command.form) || value.inputHash !== await canonicalSha256(request)) fail3();
|
|
4206
4236
|
return value;
|
|
4207
4237
|
}
|
|
4208
4238
|
async function parseAndVerifyManagedEngramExecution(raw, expected) {
|
|
4209
|
-
const value = ManagedEngramExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4239
|
+
const value = ManagedEngramExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4210
4240
|
const request = await parseAndVerifyEngramTrainingRequest(value.request);
|
|
4211
|
-
if (
|
|
4241
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || value.plan.inputHash !== await canonicalSha256(request) || value.result === null && value.resultRecordedAt !== null || value.result !== null && value.resultRecordedAt === null) fail3();
|
|
4212
4242
|
if (value.sourceForm) await checkForm(value.sourceForm, request);
|
|
4213
4243
|
if (value.result) await parseAndVerifyEngramTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
4214
4244
|
return value;
|
|
@@ -4228,8 +4258,8 @@ async function parseAndVerifyManagedEngramPrepare(raw) {
|
|
|
4228
4258
|
}
|
|
4229
4259
|
async function parseAndVerifyManagedEngramExecutionReceipt(raw, command) {
|
|
4230
4260
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedEngramPrepare(command);
|
|
4231
|
-
const value = ManagedEngramExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4232
|
-
if (
|
|
4261
|
+
const value = ManagedEngramExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4262
|
+
if (contentHash2 !== await canonicalSha256(content) || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256("action" in request ? request : { action: "prepare", command: request }) || value.execution.teamId !== request.teamId || Date.parse(value.execution.plan.expiresAt) <= Date.parse(value.execution.plan.createdAt) || value.execution.plan.maximumSpendUsd !== canonicalComputeSpendCap(value.execution.plan.maximumSpendUsd)) fail3();
|
|
4233
4263
|
if ("action" in request) {
|
|
4234
4264
|
if (value.execution.id !== request.id || value.execution.plan.contentHash !== request.planHash || value.execution.revision !== request.expectedRevision + 1 || (request.action === "start" ? value.execution.phase !== "queued" || value.execution.plan.maximumSpendUsd !== request.approvedMaximumSpendUsd || !await managedModificationPriceApprovalMatches(value.execution.plan, request) : !["cancelled", "stopping"].includes(value.execution.phase))) fail3();
|
|
4235
4265
|
} else {
|
|
@@ -4247,9 +4277,9 @@ function parseExecutionListQuery(raw = {}) {
|
|
|
4247
4277
|
));
|
|
4248
4278
|
}
|
|
4249
4279
|
async function parseAndVerifyManagedEngramExecutionPage(raw, expected) {
|
|
4250
|
-
const value = ManagedEngramExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4280
|
+
const value = ManagedEngramExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4251
4281
|
const query = parseExecutionListQuery(expected.query);
|
|
4252
|
-
if (
|
|
4282
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || canonicalJson(value.query) !== canonicalJson(query) || value.items.length > query.limit || new Set(value.items.map((item) => item.id)).size !== value.items.length) fail3();
|
|
4253
4283
|
for (const item of value.items) {
|
|
4254
4284
|
if (item.teamId !== value.teamId || item.ownerUserId !== value.ownerUserId || query.id !== void 0 && item.id !== query.id || query.projectId !== void 0 && item.projectId !== query.projectId || query.phase !== void 0 && item.phase !== query.phase || item.plan.maximumSpendUsd !== canonicalComputeSpendCap(item.plan.maximumSpendUsd) || Date.parse(item.plan.expiresAt) <= Date.parse(item.plan.createdAt)) fail3();
|
|
4255
4285
|
}
|
|
@@ -4295,62 +4325,62 @@ function createManagedEngramExecutionClient(request) {
|
|
|
4295
4325
|
}
|
|
4296
4326
|
|
|
4297
4327
|
// src/managed-decision-executions.ts
|
|
4298
|
-
import { z as
|
|
4328
|
+
import { z as z41 } from "zod";
|
|
4299
4329
|
import { assertBoundedTaskJson as assertBoundedTaskJson7 } from "@openpond/evals/task-schema";
|
|
4300
|
-
var Id25 =
|
|
4301
|
-
var Hash30 =
|
|
4302
|
-
var Money3 =
|
|
4303
|
-
var Method2 =
|
|
4304
|
-
var Mode =
|
|
4330
|
+
var Id25 = z41.string().trim().min(1).max(240);
|
|
4331
|
+
var Hash30 = z41.string().regex(/^[a-f0-9]{64}$/);
|
|
4332
|
+
var Money3 = z41.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4333
|
+
var Method2 = z41.literal("decision_model");
|
|
4334
|
+
var Mode = z41.enum(["train", "score"]);
|
|
4305
4335
|
var Query2 = ModelModificationCapabilitiesQuerySchema;
|
|
4306
|
-
var DecisionExecutionRequestSchema =
|
|
4307
|
-
var DecisionExecutionResultSchema =
|
|
4308
|
-
var DecisionExecutionCapabilityContentSchema =
|
|
4309
|
-
schemaVersion:
|
|
4336
|
+
var DecisionExecutionRequestSchema = z41.discriminatedUnion("schemaVersion", [DecisionTrainingRequestSchema, DecisionScoringRequestSchema]);
|
|
4337
|
+
var DecisionExecutionResultSchema = z41.discriminatedUnion("schemaVersion", [DecisionTrainingResultSchema, DecisionScoringResultSchema]);
|
|
4338
|
+
var DecisionExecutionCapabilityContentSchema = z41.object({
|
|
4339
|
+
schemaVersion: z41.literal("openpond.decisionExecutionCapability.v1"),
|
|
4310
4340
|
teamId: Id25,
|
|
4311
4341
|
actorId: Id25,
|
|
4312
4342
|
query: Query2,
|
|
4313
4343
|
requestHash: Hash30,
|
|
4314
|
-
checkedAt:
|
|
4315
|
-
expiresAt:
|
|
4344
|
+
checkedAt: z41.iso.datetime(),
|
|
4345
|
+
expiresAt: z41.iso.datetime(),
|
|
4316
4346
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4317
|
-
execution:
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
state:
|
|
4347
|
+
execution: z41.discriminatedUnion("state", [
|
|
4348
|
+
z41.object({ state: z41.literal("unavailable"), code: z41.enum(["model_not_supported", "runtime_not_qualified"]), reason: z41.string().min(1).max(1e3) }).strict(),
|
|
4349
|
+
z41.object({
|
|
4350
|
+
state: z41.literal("ready"),
|
|
4321
4351
|
model: DecisionModelIdentitySchema,
|
|
4322
|
-
runtime:
|
|
4352
|
+
runtime: z41.object({
|
|
4323
4353
|
id: Id25,
|
|
4324
4354
|
releaseHash: Hash30,
|
|
4325
|
-
imageDigest:
|
|
4326
|
-
requestSchemas:
|
|
4327
|
-
evidence:
|
|
4355
|
+
imageDigest: z41.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4356
|
+
requestSchemas: z41.tuple([z41.literal("openpond.decisionTrainingRequest.v1"), z41.literal("openpond.decisionScoringRequest.v1")]),
|
|
4357
|
+
evidence: z41.object({ id: Id25, contentHash: Hash30 }).strict()
|
|
4328
4358
|
}).strict(),
|
|
4329
|
-
limits:
|
|
4330
|
-
train:
|
|
4331
|
-
maximumExamples:
|
|
4332
|
-
maximumDataBytes:
|
|
4333
|
-
maximumSteps:
|
|
4334
|
-
maximumGradientAccumulationSteps:
|
|
4335
|
-
maximumPromptTokens:
|
|
4336
|
-
maximumForwardTokenWork:
|
|
4337
|
-
maximumDurationSeconds:
|
|
4338
|
-
maximumCheckpointBytes:
|
|
4359
|
+
limits: z41.object({
|
|
4360
|
+
train: z41.object({
|
|
4361
|
+
maximumExamples: z41.number().int().min(1).max(4096),
|
|
4362
|
+
maximumDataBytes: z41.number().int().positive().max(8388608),
|
|
4363
|
+
maximumSteps: z41.number().int().min(1).max(4096),
|
|
4364
|
+
maximumGradientAccumulationSteps: z41.number().int().min(1).max(64),
|
|
4365
|
+
maximumPromptTokens: z41.number().int().min(1).max(2048),
|
|
4366
|
+
maximumForwardTokenWork: z41.number().int().positive().max(536870912),
|
|
4367
|
+
maximumDurationSeconds: z41.number().finite().min(1).max(21600),
|
|
4368
|
+
maximumCheckpointBytes: z41.number().int().positive().max(268435456)
|
|
4339
4369
|
}).strict(),
|
|
4340
|
-
score:
|
|
4341
|
-
maximumQuestions:
|
|
4342
|
-
maximumChoicesPerQuestion:
|
|
4343
|
-
maximumStateBytes:
|
|
4344
|
-
maximumPromptTokens:
|
|
4345
|
-
maximumForwardTokenWork:
|
|
4346
|
-
maximumDurationSeconds:
|
|
4370
|
+
score: z41.object({
|
|
4371
|
+
maximumQuestions: z41.number().int().min(1).max(8),
|
|
4372
|
+
maximumChoicesPerQuestion: z41.number().int().min(2).max(26),
|
|
4373
|
+
maximumStateBytes: z41.number().int().positive().max(65536),
|
|
4374
|
+
maximumPromptTokens: z41.number().int().min(1).max(2048),
|
|
4375
|
+
maximumForwardTokenWork: z41.number().int().positive().max(65536),
|
|
4376
|
+
maximumDurationSeconds: z41.number().finite().positive().max(300)
|
|
4347
4377
|
}).strict()
|
|
4348
4378
|
}).strict()
|
|
4349
4379
|
}).strict()
|
|
4350
4380
|
])
|
|
4351
4381
|
}).strict();
|
|
4352
4382
|
var DecisionExecutionCapabilitySchema = DecisionExecutionCapabilityContentSchema.extend({ contentHash: Hash30 });
|
|
4353
|
-
var ManagedDecisionCompileSchema =
|
|
4383
|
+
var ManagedDecisionCompileSchema = z41.object({
|
|
4354
4384
|
teamId: Id25,
|
|
4355
4385
|
projectId: Id25.nullable(),
|
|
4356
4386
|
method: Method2,
|
|
@@ -4358,8 +4388,8 @@ var ManagedDecisionCompileSchema = z40.object({
|
|
|
4358
4388
|
query: Query2,
|
|
4359
4389
|
form: DecisionExperimentFormDraftSchema
|
|
4360
4390
|
}).strict();
|
|
4361
|
-
var ManagedDecisionCompilationContentSchema =
|
|
4362
|
-
schemaVersion:
|
|
4391
|
+
var ManagedDecisionCompilationContentSchema = z41.object({
|
|
4392
|
+
schemaVersion: z41.literal("openpond.managedDecisionCompilation.v1"),
|
|
4363
4393
|
teamId: Id25,
|
|
4364
4394
|
actorId: Id25,
|
|
4365
4395
|
projectId: Id25.nullable(),
|
|
@@ -4371,11 +4401,11 @@ var ManagedDecisionCompilationContentSchema = z40.object({
|
|
|
4371
4401
|
request: DecisionExecutionRequestSchema
|
|
4372
4402
|
}).strict();
|
|
4373
4403
|
var ManagedDecisionCompilationSchema = ManagedDecisionCompilationContentSchema.extend({ contentHash: Hash30 });
|
|
4374
|
-
var ManagedDecisionPrepareSchema =
|
|
4404
|
+
var ManagedDecisionPrepareSchema = z41.object({
|
|
4375
4405
|
teamId: Id25,
|
|
4376
4406
|
operationId: Id25,
|
|
4377
4407
|
projectId: Id25.nullable(),
|
|
4378
|
-
name:
|
|
4408
|
+
name: z41.string().trim().min(1).max(500),
|
|
4379
4409
|
method: Method2,
|
|
4380
4410
|
mode: Mode,
|
|
4381
4411
|
query: Query2,
|
|
@@ -4387,37 +4417,37 @@ var ManagedDecisionStartSchema = ManagedModificationStartSchema;
|
|
|
4387
4417
|
var ManagedDecisionCancelSchema = ManagedModificationCancelSchema;
|
|
4388
4418
|
var ManagedDecisionExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method2, mode: Mode }).strict();
|
|
4389
4419
|
var ManagedDecisionExecutionContentSchema = ManagedDecisionExecutionMetadataSchema.extend({
|
|
4390
|
-
schemaVersion:
|
|
4420
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecution.v1"),
|
|
4391
4421
|
request: DecisionExecutionRequestSchema,
|
|
4392
4422
|
sourceForm: DecisionExperimentFormDraftSchema.optional(),
|
|
4393
4423
|
result: DecisionExecutionResultSchema.nullable(),
|
|
4394
|
-
resultRecordedAt:
|
|
4424
|
+
resultRecordedAt: z41.iso.datetime().nullable()
|
|
4395
4425
|
}).strict();
|
|
4396
4426
|
var ManagedDecisionExecutionSchema = ManagedDecisionExecutionContentSchema.extend({ contentHash: Hash30 });
|
|
4397
|
-
var ManagedDecisionExecutionReceiptContentSchema =
|
|
4398
|
-
schemaVersion:
|
|
4427
|
+
var ManagedDecisionExecutionReceiptContentSchema = z41.object({
|
|
4428
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecutionReceipt.v1"),
|
|
4399
4429
|
operationId: Id25,
|
|
4400
4430
|
requestHash: Hash30,
|
|
4401
4431
|
execution: ManagedDecisionExecutionMetadataSchema
|
|
4402
4432
|
}).strict();
|
|
4403
4433
|
var ManagedDecisionExecutionReceiptSchema = ManagedDecisionExecutionReceiptContentSchema.extend({ contentHash: Hash30 });
|
|
4404
|
-
var ManagedDecisionExecutionListQuerySchema =
|
|
4434
|
+
var ManagedDecisionExecutionListQuerySchema = z41.object({
|
|
4405
4435
|
method: Method2.default("decision_model"),
|
|
4406
4436
|
mode: Mode.optional(),
|
|
4407
4437
|
id: Id25.optional(),
|
|
4408
4438
|
projectId: Id25.optional(),
|
|
4409
4439
|
phase: ManagedDecisionExecutionMetadataSchema.shape.phase.optional(),
|
|
4410
|
-
limit:
|
|
4411
|
-
cursor:
|
|
4440
|
+
limit: z41.number().int().min(1).max(100).default(25),
|
|
4441
|
+
cursor: z41.string().min(1).max(2048).optional()
|
|
4412
4442
|
}).strict();
|
|
4413
4443
|
var ManagedDecisionExecutionSummarySchema = ManagedDecisionExecutionMetadataSchema.extend({ model: DecisionModelIdentitySchema }).strict();
|
|
4414
|
-
var ManagedDecisionExecutionPageContentSchema =
|
|
4415
|
-
schemaVersion:
|
|
4444
|
+
var ManagedDecisionExecutionPageContentSchema = z41.object({
|
|
4445
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecutionPage.v1"),
|
|
4416
4446
|
teamId: Id25,
|
|
4417
4447
|
ownerUserId: Id25,
|
|
4418
4448
|
query: ManagedDecisionExecutionListQuerySchema,
|
|
4419
|
-
items:
|
|
4420
|
-
nextCursor:
|
|
4449
|
+
items: z41.array(ManagedDecisionExecutionSummarySchema).max(100),
|
|
4450
|
+
nextCursor: z41.string().min(1).max(2048).nullable()
|
|
4421
4451
|
}).strict();
|
|
4422
4452
|
var ManagedDecisionExecutionPageSchema = ManagedDecisionExecutionPageContentSchema.extend({ contentHash: Hash30 });
|
|
4423
4453
|
function fail4() {
|
|
@@ -4485,10 +4515,10 @@ function checkPlan(metadata) {
|
|
|
4485
4515
|
if (metadata.plan.maximumSpendUsd !== canonicalComputeSpendCap(metadata.plan.maximumSpendUsd) || Date.parse(metadata.plan.expiresAt) <= Date.parse(metadata.plan.createdAt)) fail4();
|
|
4486
4516
|
}
|
|
4487
4517
|
async function parseAndVerifyDecisionExecutionCapability(raw, input, actorId) {
|
|
4488
|
-
const query = Query2.parse(input), value = DecisionExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4518
|
+
const query = Query2.parse(input), value = DecisionExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4489
4519
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4490
4520
|
const checked = Date.parse(value.checkedAt), expiry = Date.parse(value.expiresAt);
|
|
4491
|
-
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) ||
|
|
4521
|
+
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || contentHash2 !== await canonicalSha256(content) || checked > Date.now() + 3e4 || expiry <= Date.now() || expiry <= checked || expiry - checked > 3e5) fail4();
|
|
4492
4522
|
if (value.execution.state === "ready") {
|
|
4493
4523
|
await parseAndVerifyDecisionModelIdentity(value.execution.model);
|
|
4494
4524
|
checkSource2(query, value.execution.model);
|
|
@@ -4523,11 +4553,11 @@ function parseManagedDecisionCompile(raw) {
|
|
|
4523
4553
|
return value;
|
|
4524
4554
|
}
|
|
4525
4555
|
async function parseAndVerifyManagedDecisionCompilation(raw, input, actorId) {
|
|
4526
|
-
const command = parseManagedDecisionCompile(input), value = ManagedDecisionCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4556
|
+
const command = parseManagedDecisionCompile(input), value = ManagedDecisionCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4527
4557
|
const request = await verifyRequest(value.request);
|
|
4528
4558
|
checkSource2(command.query, request.model);
|
|
4529
4559
|
await checkForm2(command.form, request);
|
|
4530
|
-
if (
|
|
4560
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== command.teamId || value.projectId !== command.projectId || actorId !== void 0 && value.actorId !== actorId || value.mode !== command.mode || value.mode !== requestMode(request) || canonicalJson(value.query) !== canonicalJson(command.query) || value.formHash !== await canonicalSha256(command.form) || value.inputHash !== await canonicalSha256(request)) fail4();
|
|
4531
4561
|
return value;
|
|
4532
4562
|
}
|
|
4533
4563
|
async function parseAndVerifyManagedDecisionPrepare(raw) {
|
|
@@ -4545,10 +4575,10 @@ async function parseAndVerifyManagedDecisionPrepare(raw) {
|
|
|
4545
4575
|
}
|
|
4546
4576
|
async function parseAndVerifyManagedDecisionExecution(raw, expected) {
|
|
4547
4577
|
assertBoundedTaskJson7(raw, 1048576);
|
|
4548
|
-
const value = ManagedDecisionExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4578
|
+
const value = ManagedDecisionExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4549
4579
|
const request = await verifyRequest(value.request);
|
|
4550
4580
|
checkPlan(value);
|
|
4551
|
-
if (
|
|
4581
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || value.mode !== requestMode(request) || value.plan.inputHash !== await canonicalSha256(request) || value.result === null && value.resultRecordedAt !== null || value.result !== null && value.resultRecordedAt === null || value.phase === "completed" && value.result === null) fail4();
|
|
4552
4582
|
if (value.sourceForm) {
|
|
4553
4583
|
await checkForm2(value.sourceForm, request);
|
|
4554
4584
|
if (value.sourceForm.name.trim() !== value.name || canonicalComputeSpendCap(value.sourceForm.maximumSpendUsd) !== value.plan.maximumSpendUsd) fail4();
|
|
@@ -4564,10 +4594,10 @@ async function parseAndVerifyManagedDecisionExecution(raw, expected) {
|
|
|
4564
4594
|
}
|
|
4565
4595
|
async function parseAndVerifyManagedDecisionExecutionReceipt(raw, input, ownerUserId) {
|
|
4566
4596
|
const command = "action" in input ? parseManagedModificationControl(input) : await parseAndVerifyManagedDecisionPrepare(input);
|
|
4567
|
-
const value = ManagedDecisionExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4597
|
+
const value = ManagedDecisionExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4568
4598
|
const metadata = value.execution;
|
|
4569
4599
|
checkPlan(metadata);
|
|
4570
|
-
if (
|
|
4600
|
+
if (contentHash2 !== await canonicalSha256(content) || value.operationId !== command.operationId || metadata.teamId !== command.teamId || ownerUserId !== void 0 && metadata.ownerUserId !== ownerUserId || value.requestHash !== await canonicalSha256("action" in command ? command : { action: "prepare", command })) fail4();
|
|
4571
4601
|
if ("action" in command) {
|
|
4572
4602
|
if (metadata.id !== command.id || metadata.plan.contentHash !== command.planHash || metadata.revision !== command.expectedRevision + 1 || (command.action === "start" ? metadata.phase !== "queued" || metadata.plan.maximumSpendUsd !== command.approvedMaximumSpendUsd || !await managedModificationPriceApprovalMatches(metadata.plan, command) : !["cancelled", "stopping"].includes(metadata.phase))) fail4();
|
|
4573
4603
|
} else if (metadata.projectId !== command.projectId || metadata.name !== command.name || metadata.mode !== command.mode || metadata.plan.inputHash !== await canonicalSha256(command.request) || metadata.plan.maximumSpendUsd !== command.maximumSpendUsd || metadata.phase !== "prepared" || metadata.revision !== 1 || metadata.id !== `modification-${await canonicalSha256({ teamId: command.teamId, ownerUserId: metadata.ownerUserId, operationId: command.operationId })}`) fail4();
|
|
@@ -4580,9 +4610,9 @@ function parseExecutionListQuery2(raw = {}) {
|
|
|
4580
4610
|
));
|
|
4581
4611
|
}
|
|
4582
4612
|
async function parseAndVerifyManagedDecisionExecutionPage(raw, expected) {
|
|
4583
|
-
const value = ManagedDecisionExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4613
|
+
const value = ManagedDecisionExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4584
4614
|
const query = parseExecutionListQuery2(expected.query);
|
|
4585
|
-
if (
|
|
4615
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || canonicalJson(value.query) !== canonicalJson(query) || value.items.length > query.limit || new Set(value.items.map((item) => item.id)).size !== value.items.length || value.nextCursor !== null && (value.items.length !== query.limit || value.nextCursor === query.cursor)) fail4();
|
|
4586
4616
|
for (const [index, item] of value.items.entries()) {
|
|
4587
4617
|
const previous = value.items[index - 1];
|
|
4588
4618
|
checkPlan(item);
|
|
@@ -4631,54 +4661,54 @@ function createManagedDecisionExecutionClient(request) {
|
|
|
4631
4661
|
}
|
|
4632
4662
|
|
|
4633
4663
|
// src/managed-alphaedit-executions.ts
|
|
4634
|
-
import { z as
|
|
4635
|
-
var Id26 =
|
|
4636
|
-
var Hash31 =
|
|
4637
|
-
var Money4 =
|
|
4638
|
-
var Method3 =
|
|
4664
|
+
import { z as z42 } from "zod";
|
|
4665
|
+
var Id26 = z42.string().trim().min(1).max(240);
|
|
4666
|
+
var Hash31 = z42.string().regex(/^[a-f0-9]{64}$/);
|
|
4667
|
+
var Money4 = z42.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4668
|
+
var Method3 = z42.literal("alphaedit");
|
|
4639
4669
|
var Query3 = ModelModificationCapabilitiesQuerySchema;
|
|
4640
|
-
var AlphaEditExecutionCapabilityContentSchema =
|
|
4641
|
-
schemaVersion:
|
|
4670
|
+
var AlphaEditExecutionCapabilityContentSchema = z42.object({
|
|
4671
|
+
schemaVersion: z42.literal("openpond.alphaEditExecutionCapability.v1"),
|
|
4642
4672
|
teamId: Id26,
|
|
4643
4673
|
actorId: Id26,
|
|
4644
4674
|
query: Query3,
|
|
4645
4675
|
requestHash: Hash31,
|
|
4646
|
-
checkedAt:
|
|
4647
|
-
expiresAt:
|
|
4676
|
+
checkedAt: z42.iso.datetime(),
|
|
4677
|
+
expiresAt: z42.iso.datetime(),
|
|
4648
4678
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4649
|
-
execution:
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
state:
|
|
4679
|
+
execution: z42.discriminatedUnion("state", [
|
|
4680
|
+
z42.object({ state: z42.literal("unavailable"), code: z42.enum(["model_not_supported", "runtime_not_qualified"]), reason: z42.string().min(1).max(1e3) }).strict(),
|
|
4681
|
+
z42.object({
|
|
4682
|
+
state: z42.literal("ready"),
|
|
4653
4683
|
model: NeuronSteeringModelSchema,
|
|
4654
|
-
runtime:
|
|
4684
|
+
runtime: z42.object({
|
|
4655
4685
|
id: Id26,
|
|
4656
4686
|
releaseHash: Hash31,
|
|
4657
|
-
imageDigest:
|
|
4658
|
-
requestSchema:
|
|
4659
|
-
evidence:
|
|
4687
|
+
imageDigest: z42.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4688
|
+
requestSchema: z42.literal("openpond.alphaEditTrainingRequest.v1"),
|
|
4689
|
+
evidence: z42.object({ id: Id26, contentHash: Hash31 }).strict()
|
|
4660
4690
|
}).strict(),
|
|
4661
|
-
limits:
|
|
4662
|
-
maximumExamples:
|
|
4663
|
-
maximumDataBytes:
|
|
4664
|
-
maximumSteps:
|
|
4665
|
-
maximumSequenceLength:
|
|
4666
|
-
maximumDurationSeconds:
|
|
4667
|
-
maximumCheckpointBytes:
|
|
4691
|
+
limits: z42.object({
|
|
4692
|
+
maximumExamples: z42.number().int().min(1).max(4096),
|
|
4693
|
+
maximumDataBytes: z42.number().int().positive().max(8388608),
|
|
4694
|
+
maximumSteps: z42.number().int().min(1).max(128),
|
|
4695
|
+
maximumSequenceLength: z42.number().int().min(2).max(8192),
|
|
4696
|
+
maximumDurationSeconds: z42.number().finite().min(1).max(21600),
|
|
4697
|
+
maximumCheckpointBytes: z42.number().int().positive().max(17179869184)
|
|
4668
4698
|
}).strict()
|
|
4669
4699
|
}).strict()
|
|
4670
4700
|
])
|
|
4671
4701
|
}).strict();
|
|
4672
4702
|
var AlphaEditExecutionCapabilitySchema = AlphaEditExecutionCapabilityContentSchema.extend({ contentHash: Hash31 });
|
|
4673
|
-
var ManagedAlphaEditCompileSchema =
|
|
4703
|
+
var ManagedAlphaEditCompileSchema = z42.object({
|
|
4674
4704
|
teamId: Id26,
|
|
4675
4705
|
projectId: Id26.nullable(),
|
|
4676
4706
|
method: Method3,
|
|
4677
4707
|
query: Query3,
|
|
4678
4708
|
form: AlphaEditExperimentFormDraftSchema
|
|
4679
4709
|
}).strict();
|
|
4680
|
-
var ManagedAlphaEditCompilationContentSchema =
|
|
4681
|
-
schemaVersion:
|
|
4710
|
+
var ManagedAlphaEditCompilationContentSchema = z42.object({
|
|
4711
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditCompilation.v1"),
|
|
4682
4712
|
teamId: Id26,
|
|
4683
4713
|
actorId: Id26,
|
|
4684
4714
|
projectId: Id26.nullable(),
|
|
@@ -4689,11 +4719,11 @@ var ManagedAlphaEditCompilationContentSchema = z41.object({
|
|
|
4689
4719
|
request: AlphaEditTrainingRequestSchema
|
|
4690
4720
|
}).strict();
|
|
4691
4721
|
var ManagedAlphaEditCompilationSchema = ManagedAlphaEditCompilationContentSchema.extend({ contentHash: Hash31 });
|
|
4692
|
-
var ManagedAlphaEditPrepareSchema =
|
|
4722
|
+
var ManagedAlphaEditPrepareSchema = z42.object({
|
|
4693
4723
|
teamId: Id26,
|
|
4694
4724
|
operationId: Id26,
|
|
4695
4725
|
projectId: Id26.nullable(),
|
|
4696
|
-
name:
|
|
4726
|
+
name: z42.string().trim().min(1).max(500),
|
|
4697
4727
|
method: Method3,
|
|
4698
4728
|
query: Query3,
|
|
4699
4729
|
request: AlphaEditTrainingRequestSchema,
|
|
@@ -4704,36 +4734,36 @@ var ManagedAlphaEditStartSchema = ManagedModificationStartSchema;
|
|
|
4704
4734
|
var ManagedAlphaEditCancelSchema = ManagedModificationCancelSchema;
|
|
4705
4735
|
var ManagedAlphaEditExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method3 }).strict();
|
|
4706
4736
|
var ManagedAlphaEditExecutionContentSchema = ManagedAlphaEditExecutionMetadataSchema.extend({
|
|
4707
|
-
schemaVersion:
|
|
4737
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecution.v1"),
|
|
4708
4738
|
request: AlphaEditTrainingRequestSchema,
|
|
4709
4739
|
sourceForm: AlphaEditExperimentFormDraftSchema.optional(),
|
|
4710
4740
|
result: AlphaEditTrainingResultSchema.nullable(),
|
|
4711
|
-
resultRecordedAt:
|
|
4741
|
+
resultRecordedAt: z42.iso.datetime().nullable()
|
|
4712
4742
|
}).strict();
|
|
4713
4743
|
var ManagedAlphaEditExecutionSchema = ManagedAlphaEditExecutionContentSchema.extend({ contentHash: Hash31 });
|
|
4714
|
-
var ManagedAlphaEditExecutionReceiptContentSchema =
|
|
4715
|
-
schemaVersion:
|
|
4744
|
+
var ManagedAlphaEditExecutionReceiptContentSchema = z42.object({
|
|
4745
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecutionReceipt.v1"),
|
|
4716
4746
|
operationId: Id26,
|
|
4717
4747
|
requestHash: Hash31,
|
|
4718
4748
|
execution: ManagedAlphaEditExecutionMetadataSchema
|
|
4719
4749
|
}).strict();
|
|
4720
4750
|
var ManagedAlphaEditExecutionReceiptSchema = ManagedAlphaEditExecutionReceiptContentSchema.extend({ contentHash: Hash31 });
|
|
4721
|
-
var ManagedAlphaEditExecutionListQuerySchema =
|
|
4751
|
+
var ManagedAlphaEditExecutionListQuerySchema = z42.object({
|
|
4722
4752
|
method: Method3.default("alphaedit"),
|
|
4723
4753
|
id: Id26.optional(),
|
|
4724
4754
|
projectId: Id26.optional(),
|
|
4725
4755
|
phase: ManagedAlphaEditExecutionMetadataSchema.shape.phase.optional(),
|
|
4726
|
-
limit:
|
|
4727
|
-
cursor:
|
|
4756
|
+
limit: z42.number().int().min(1).max(100).default(25),
|
|
4757
|
+
cursor: z42.string().min(1).max(2048).optional()
|
|
4728
4758
|
}).strict();
|
|
4729
4759
|
var ManagedAlphaEditExecutionSummarySchema = ManagedAlphaEditExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4730
|
-
var ManagedAlphaEditExecutionPageContentSchema =
|
|
4731
|
-
schemaVersion:
|
|
4760
|
+
var ManagedAlphaEditExecutionPageContentSchema = z42.object({
|
|
4761
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecutionPage.v1"),
|
|
4732
4762
|
teamId: Id26,
|
|
4733
4763
|
ownerUserId: Id26,
|
|
4734
4764
|
query: ManagedAlphaEditExecutionListQuerySchema,
|
|
4735
|
-
items:
|
|
4736
|
-
nextCursor:
|
|
4765
|
+
items: z42.array(ManagedAlphaEditExecutionSummarySchema).max(100),
|
|
4766
|
+
nextCursor: z42.string().min(1).max(2048).nullable()
|
|
4737
4767
|
}).strict();
|
|
4738
4768
|
var ManagedAlphaEditExecutionPageSchema = ManagedAlphaEditExecutionPageContentSchema.extend({ contentHash: Hash31 });
|
|
4739
4769
|
function parseAlphaEditFormTraining(raw) {
|
|
@@ -4786,26 +4816,26 @@ function checkFormQuery2(form, query) {
|
|
|
4786
4816
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail5();
|
|
4787
4817
|
}
|
|
4788
4818
|
async function parseAndVerifyAlphaEditExecutionCapability(raw, queryInput, actorId) {
|
|
4789
|
-
const query = Query3.parse(queryInput), value = AlphaEditExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4819
|
+
const query = Query3.parse(queryInput), value = AlphaEditExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4790
4820
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4791
4821
|
const checked = Date.parse(value.checkedAt), expires = Date.parse(value.expiresAt);
|
|
4792
|
-
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) ||
|
|
4822
|
+
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || contentHash2 !== await canonicalSha256(content) || checked > Date.now() + 3e4 || expires <= Date.now() || expires <= checked || expires - checked > 3e5) fail5();
|
|
4793
4823
|
if (value.execution.state === "ready") checkSource3(query, { model: value.execution.model });
|
|
4794
4824
|
return value;
|
|
4795
4825
|
}
|
|
4796
4826
|
async function parseAndVerifyManagedAlphaEditCompilation(raw, input) {
|
|
4797
|
-
const command = ManagedAlphaEditCompileSchema.parse(input), value = ManagedAlphaEditCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4827
|
+
const command = ManagedAlphaEditCompileSchema.parse(input), value = ManagedAlphaEditCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4798
4828
|
const request = await parseAndVerifyAlphaEditTrainingRequest(value.request);
|
|
4799
4829
|
checkSource3(command.query, request);
|
|
4800
4830
|
await checkForm3(command.form, request);
|
|
4801
4831
|
checkFormQuery2(command.form, command.query);
|
|
4802
|
-
if (
|
|
4832
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== command.teamId || command.query.teamId !== command.teamId || value.projectId !== command.projectId || canonicalJson(value.query) !== canonicalJson(command.query) || value.formHash !== await canonicalSha256(command.form) || value.inputHash !== await canonicalSha256(request)) fail5();
|
|
4803
4833
|
return value;
|
|
4804
4834
|
}
|
|
4805
4835
|
async function parseAndVerifyManagedAlphaEditExecution(raw, expected) {
|
|
4806
|
-
const value = ManagedAlphaEditExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4836
|
+
const value = ManagedAlphaEditExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4807
4837
|
const request = await parseAndVerifyAlphaEditTrainingRequest(value.request);
|
|
4808
|
-
if (
|
|
4838
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || value.plan.inputHash !== await canonicalSha256(request) || value.result === null && value.resultRecordedAt !== null || value.result !== null && value.resultRecordedAt === null) fail5();
|
|
4809
4839
|
if (value.sourceForm) await checkForm3(value.sourceForm, request);
|
|
4810
4840
|
if (value.result) await parseAndVerifyAlphaEditTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
4811
4841
|
return value;
|
|
@@ -4825,8 +4855,8 @@ async function parseAndVerifyManagedAlphaEditPrepare(raw) {
|
|
|
4825
4855
|
}
|
|
4826
4856
|
async function parseAndVerifyManagedAlphaEditExecutionReceipt(raw, command) {
|
|
4827
4857
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedAlphaEditPrepare(command);
|
|
4828
|
-
const value = ManagedAlphaEditExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4829
|
-
if (
|
|
4858
|
+
const value = ManagedAlphaEditExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4859
|
+
if (contentHash2 !== await canonicalSha256(content) || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256("action" in request ? request : { action: "prepare", command: request }) || value.execution.teamId !== request.teamId || Date.parse(value.execution.plan.expiresAt) <= Date.parse(value.execution.plan.createdAt) || value.execution.plan.maximumSpendUsd !== canonicalComputeSpendCap(value.execution.plan.maximumSpendUsd)) fail5();
|
|
4830
4860
|
if ("action" in request) {
|
|
4831
4861
|
if (value.execution.id !== request.id || value.execution.plan.contentHash !== request.planHash || value.execution.revision !== request.expectedRevision + 1 || (request.action === "start" ? value.execution.phase !== "queued" || value.execution.plan.maximumSpendUsd !== request.approvedMaximumSpendUsd || !await managedModificationPriceApprovalMatches(value.execution.plan, request) : !["cancelled", "stopping"].includes(value.execution.phase))) fail5();
|
|
4832
4862
|
} else {
|
|
@@ -4844,9 +4874,9 @@ function parseExecutionListQuery3(raw = {}) {
|
|
|
4844
4874
|
));
|
|
4845
4875
|
}
|
|
4846
4876
|
async function parseAndVerifyManagedAlphaEditExecutionPage(raw, expected) {
|
|
4847
|
-
const value = ManagedAlphaEditExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4877
|
+
const value = ManagedAlphaEditExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4848
4878
|
const query = parseExecutionListQuery3(expected.query);
|
|
4849
|
-
if (
|
|
4879
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || canonicalJson(value.query) !== canonicalJson(query) || value.items.length > query.limit || new Set(value.items.map((item) => item.id)).size !== value.items.length) fail5();
|
|
4850
4880
|
for (const item of value.items) {
|
|
4851
4881
|
if (item.teamId !== value.teamId || item.ownerUserId !== value.ownerUserId || query.id !== void 0 && item.id !== query.id || query.projectId !== void 0 && item.projectId !== query.projectId || query.phase !== void 0 && item.phase !== query.phase || item.plan.maximumSpendUsd !== canonicalComputeSpendCap(item.plan.maximumSpendUsd) || Date.parse(item.plan.expiresAt) <= Date.parse(item.plan.createdAt)) fail5();
|
|
4852
4882
|
}
|
|
@@ -4892,54 +4922,54 @@ function createManagedAlphaEditExecutionClient(request) {
|
|
|
4892
4922
|
}
|
|
4893
4923
|
|
|
4894
4924
|
// src/managed-neuron-training-executions.ts
|
|
4895
|
-
import { z as
|
|
4896
|
-
var Id27 =
|
|
4897
|
-
var Hash32 =
|
|
4898
|
-
var Money5 =
|
|
4899
|
-
var Method4 =
|
|
4925
|
+
import { z as z43 } from "zod";
|
|
4926
|
+
var Id27 = z43.string().trim().min(1).max(240);
|
|
4927
|
+
var Hash32 = z43.string().regex(/^[a-f0-9]{64}$/);
|
|
4928
|
+
var Money5 = z43.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4929
|
+
var Method4 = z43.literal("selective_neuron_training");
|
|
4900
4930
|
var Query4 = ModelModificationCapabilitiesQuerySchema;
|
|
4901
|
-
var NeuronTrainingExecutionCapabilityContentSchema =
|
|
4902
|
-
schemaVersion:
|
|
4931
|
+
var NeuronTrainingExecutionCapabilityContentSchema = z43.object({
|
|
4932
|
+
schemaVersion: z43.literal("openpond.neuronTrainingExecutionCapability.v1"),
|
|
4903
4933
|
teamId: Id27,
|
|
4904
4934
|
actorId: Id27,
|
|
4905
4935
|
query: Query4,
|
|
4906
4936
|
requestHash: Hash32,
|
|
4907
|
-
checkedAt:
|
|
4908
|
-
expiresAt:
|
|
4937
|
+
checkedAt: z43.iso.datetime(),
|
|
4938
|
+
expiresAt: z43.iso.datetime(),
|
|
4909
4939
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4910
|
-
execution:
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
state:
|
|
4940
|
+
execution: z43.discriminatedUnion("state", [
|
|
4941
|
+
z43.object({ state: z43.literal("unavailable"), code: z43.enum(["model_not_supported", "runtime_not_qualified"]), reason: z43.string().min(1).max(1e3) }).strict(),
|
|
4942
|
+
z43.object({
|
|
4943
|
+
state: z43.literal("ready"),
|
|
4914
4944
|
model: NeuronSteeringModelSchema,
|
|
4915
|
-
runtime:
|
|
4945
|
+
runtime: z43.object({
|
|
4916
4946
|
id: Id27,
|
|
4917
4947
|
releaseHash: Hash32,
|
|
4918
|
-
imageDigest:
|
|
4919
|
-
requestSchema:
|
|
4920
|
-
evidence:
|
|
4948
|
+
imageDigest: z43.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4949
|
+
requestSchema: z43.literal("openpond.selectiveNeuronTrainingRequest.v1"),
|
|
4950
|
+
evidence: z43.object({ id: Id27, contentHash: Hash32 }).strict()
|
|
4921
4951
|
}).strict(),
|
|
4922
|
-
limits:
|
|
4923
|
-
maximumExamples:
|
|
4924
|
-
maximumDataBytes:
|
|
4925
|
-
maximumSteps:
|
|
4926
|
-
maximumSequenceLength:
|
|
4927
|
-
maximumDurationSeconds:
|
|
4928
|
-
maximumCheckpointBytes:
|
|
4952
|
+
limits: z43.object({
|
|
4953
|
+
maximumExamples: z43.number().int().min(1).max(4096),
|
|
4954
|
+
maximumDataBytes: z43.number().int().positive().max(8388608),
|
|
4955
|
+
maximumSteps: z43.number().int().min(1).max(128),
|
|
4956
|
+
maximumSequenceLength: z43.number().int().min(2).max(8192),
|
|
4957
|
+
maximumDurationSeconds: z43.number().finite().min(1).max(21600),
|
|
4958
|
+
maximumCheckpointBytes: z43.number().int().positive().max(16777216)
|
|
4929
4959
|
}).strict()
|
|
4930
4960
|
}).strict()
|
|
4931
4961
|
])
|
|
4932
4962
|
}).strict();
|
|
4933
4963
|
var NeuronTrainingExecutionCapabilitySchema = NeuronTrainingExecutionCapabilityContentSchema.extend({ contentHash: Hash32 });
|
|
4934
|
-
var ManagedNeuronTrainingCompileSchema =
|
|
4964
|
+
var ManagedNeuronTrainingCompileSchema = z43.object({
|
|
4935
4965
|
teamId: Id27,
|
|
4936
4966
|
projectId: Id27.nullable(),
|
|
4937
4967
|
method: Method4,
|
|
4938
4968
|
query: Query4,
|
|
4939
4969
|
form: NeuronTrainingExperimentFormDraftSchema
|
|
4940
4970
|
}).strict();
|
|
4941
|
-
var ManagedNeuronTrainingCompilationContentSchema =
|
|
4942
|
-
schemaVersion:
|
|
4971
|
+
var ManagedNeuronTrainingCompilationContentSchema = z43.object({
|
|
4972
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingCompilation.v1"),
|
|
4943
4973
|
teamId: Id27,
|
|
4944
4974
|
actorId: Id27,
|
|
4945
4975
|
projectId: Id27.nullable(),
|
|
@@ -4950,11 +4980,11 @@ var ManagedNeuronTrainingCompilationContentSchema = z42.object({
|
|
|
4950
4980
|
request: NeuronTrainingRequestSchema
|
|
4951
4981
|
}).strict();
|
|
4952
4982
|
var ManagedNeuronTrainingCompilationSchema = ManagedNeuronTrainingCompilationContentSchema.extend({ contentHash: Hash32 });
|
|
4953
|
-
var ManagedNeuronTrainingPrepareSchema =
|
|
4983
|
+
var ManagedNeuronTrainingPrepareSchema = z43.object({
|
|
4954
4984
|
teamId: Id27,
|
|
4955
4985
|
operationId: Id27,
|
|
4956
4986
|
projectId: Id27.nullable(),
|
|
4957
|
-
name:
|
|
4987
|
+
name: z43.string().trim().min(1).max(500),
|
|
4958
4988
|
method: Method4,
|
|
4959
4989
|
query: Query4,
|
|
4960
4990
|
request: NeuronTrainingRequestSchema,
|
|
@@ -4965,36 +4995,36 @@ var ManagedNeuronTrainingStartSchema = ManagedModificationStartSchema;
|
|
|
4965
4995
|
var ManagedNeuronTrainingCancelSchema = ManagedModificationCancelSchema;
|
|
4966
4996
|
var ManagedNeuronTrainingExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method4 }).strict();
|
|
4967
4997
|
var ManagedNeuronTrainingExecutionContentSchema = ManagedNeuronTrainingExecutionMetadataSchema.extend({
|
|
4968
|
-
schemaVersion:
|
|
4998
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecution.v1"),
|
|
4969
4999
|
request: NeuronTrainingRequestSchema,
|
|
4970
5000
|
sourceForm: NeuronTrainingExperimentFormDraftSchema.optional(),
|
|
4971
5001
|
result: NeuronTrainingResultSchema.nullable(),
|
|
4972
|
-
resultRecordedAt:
|
|
5002
|
+
resultRecordedAt: z43.iso.datetime().nullable()
|
|
4973
5003
|
}).strict();
|
|
4974
5004
|
var ManagedNeuronTrainingExecutionSchema = ManagedNeuronTrainingExecutionContentSchema.extend({ contentHash: Hash32 });
|
|
4975
|
-
var ManagedNeuronTrainingExecutionReceiptContentSchema =
|
|
4976
|
-
schemaVersion:
|
|
5005
|
+
var ManagedNeuronTrainingExecutionReceiptContentSchema = z43.object({
|
|
5006
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecutionReceipt.v1"),
|
|
4977
5007
|
operationId: Id27,
|
|
4978
5008
|
requestHash: Hash32,
|
|
4979
5009
|
execution: ManagedNeuronTrainingExecutionMetadataSchema
|
|
4980
5010
|
}).strict();
|
|
4981
5011
|
var ManagedNeuronTrainingExecutionReceiptSchema = ManagedNeuronTrainingExecutionReceiptContentSchema.extend({ contentHash: Hash32 });
|
|
4982
|
-
var ManagedNeuronTrainingExecutionListQuerySchema =
|
|
5012
|
+
var ManagedNeuronTrainingExecutionListQuerySchema = z43.object({
|
|
4983
5013
|
method: Method4.default("selective_neuron_training"),
|
|
4984
5014
|
id: Id27.optional(),
|
|
4985
5015
|
projectId: Id27.optional(),
|
|
4986
5016
|
phase: ManagedNeuronTrainingExecutionMetadataSchema.shape.phase.optional(),
|
|
4987
|
-
limit:
|
|
4988
|
-
cursor:
|
|
5017
|
+
limit: z43.number().int().min(1).max(100).default(25),
|
|
5018
|
+
cursor: z43.string().min(1).max(2048).optional()
|
|
4989
5019
|
}).strict();
|
|
4990
5020
|
var ManagedNeuronTrainingExecutionSummarySchema = ManagedNeuronTrainingExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4991
|
-
var ManagedNeuronTrainingExecutionPageContentSchema =
|
|
4992
|
-
schemaVersion:
|
|
5021
|
+
var ManagedNeuronTrainingExecutionPageContentSchema = z43.object({
|
|
5022
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecutionPage.v1"),
|
|
4993
5023
|
teamId: Id27,
|
|
4994
5024
|
ownerUserId: Id27,
|
|
4995
5025
|
query: ManagedNeuronTrainingExecutionListQuerySchema,
|
|
4996
|
-
items:
|
|
4997
|
-
nextCursor:
|
|
5026
|
+
items: z43.array(ManagedNeuronTrainingExecutionSummarySchema).max(100),
|
|
5027
|
+
nextCursor: z43.string().min(1).max(2048).nullable()
|
|
4998
5028
|
}).strict();
|
|
4999
5029
|
var ManagedNeuronTrainingExecutionPageSchema = ManagedNeuronTrainingExecutionPageContentSchema.extend({ contentHash: Hash32 });
|
|
5000
5030
|
function parseNeuronTrainingFormTraining(raw) {
|
|
@@ -5046,26 +5076,26 @@ function checkFormQuery3(form, query) {
|
|
|
5046
5076
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail6();
|
|
5047
5077
|
}
|
|
5048
5078
|
async function parseAndVerifyNeuronTrainingExecutionCapability(raw, queryInput, actorId) {
|
|
5049
|
-
const query = Query4.parse(queryInput), value = NeuronTrainingExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
5079
|
+
const query = Query4.parse(queryInput), value = NeuronTrainingExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5050
5080
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
5051
5081
|
const checked = Date.parse(value.checkedAt), expires = Date.parse(value.expiresAt);
|
|
5052
|
-
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) ||
|
|
5082
|
+
if (value.teamId !== query.teamId || actorId !== void 0 && value.actorId !== actorId || canonicalJson(value.query) !== canonicalJson(query) || value.requestHash !== await canonicalSha256(query) || contentHash2 !== await canonicalSha256(content) || checked > Date.now() + 3e4 || expires <= Date.now() || expires <= checked || expires - checked > 3e5) fail6();
|
|
5053
5083
|
if (value.execution.state === "ready") checkSource4(query, { model: value.execution.model });
|
|
5054
5084
|
return value;
|
|
5055
5085
|
}
|
|
5056
5086
|
async function parseAndVerifyManagedNeuronTrainingCompilation(raw, input) {
|
|
5057
|
-
const command = ManagedNeuronTrainingCompileSchema.parse(input), value = ManagedNeuronTrainingCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
5087
|
+
const command = ManagedNeuronTrainingCompileSchema.parse(input), value = ManagedNeuronTrainingCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5058
5088
|
const request = await parseAndVerifyNeuronTrainingRequest(value.request);
|
|
5059
5089
|
checkSource4(command.query, request);
|
|
5060
5090
|
await checkForm4(command.form, request);
|
|
5061
5091
|
checkFormQuery3(command.form, command.query);
|
|
5062
|
-
if (
|
|
5092
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== command.teamId || command.query.teamId !== command.teamId || value.projectId !== command.projectId || canonicalJson(value.query) !== canonicalJson(command.query) || value.formHash !== await canonicalSha256(command.form) || value.inputHash !== await canonicalSha256(request)) fail6();
|
|
5063
5093
|
return value;
|
|
5064
5094
|
}
|
|
5065
5095
|
async function parseAndVerifyManagedNeuronTrainingExecution(raw, expected) {
|
|
5066
|
-
const value = ManagedNeuronTrainingExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
5096
|
+
const value = ManagedNeuronTrainingExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5067
5097
|
const request = await parseAndVerifyNeuronTrainingRequest(value.request);
|
|
5068
|
-
if (
|
|
5098
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.id !== expected.id || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || value.plan.inputHash !== await canonicalSha256(request) || value.result === null && value.resultRecordedAt !== null || value.result !== null && value.resultRecordedAt === null) fail6();
|
|
5069
5099
|
if (value.sourceForm) await checkForm4(value.sourceForm, request);
|
|
5070
5100
|
if (value.result) await parseAndVerifyNeuronTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
5071
5101
|
return value;
|
|
@@ -5085,8 +5115,8 @@ async function parseAndVerifyManagedNeuronTrainingPrepare(raw) {
|
|
|
5085
5115
|
}
|
|
5086
5116
|
async function parseAndVerifyManagedNeuronTrainingExecutionReceipt(raw, command) {
|
|
5087
5117
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedNeuronTrainingPrepare(command);
|
|
5088
|
-
const value = ManagedNeuronTrainingExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5089
|
-
if (
|
|
5118
|
+
const value = ManagedNeuronTrainingExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5119
|
+
if (contentHash2 !== await canonicalSha256(content) || value.operationId !== request.operationId || value.requestHash !== await canonicalSha256("action" in request ? request : { action: "prepare", command: request }) || value.execution.teamId !== request.teamId || Date.parse(value.execution.plan.expiresAt) <= Date.parse(value.execution.plan.createdAt) || value.execution.plan.maximumSpendUsd !== canonicalComputeSpendCap(value.execution.plan.maximumSpendUsd)) fail6();
|
|
5090
5120
|
if ("action" in request) {
|
|
5091
5121
|
if (value.execution.id !== request.id || value.execution.plan.contentHash !== request.planHash || value.execution.revision !== request.expectedRevision + 1 || (request.action === "start" ? value.execution.phase !== "queued" || value.execution.plan.maximumSpendUsd !== request.approvedMaximumSpendUsd || !await managedModificationPriceApprovalMatches(value.execution.plan, request) : !["cancelled", "stopping"].includes(value.execution.phase))) fail6();
|
|
5092
5122
|
} else {
|
|
@@ -5104,9 +5134,9 @@ function parseExecutionListQuery4(raw = {}) {
|
|
|
5104
5134
|
));
|
|
5105
5135
|
}
|
|
5106
5136
|
async function parseAndVerifyManagedNeuronTrainingExecutionPage(raw, expected) {
|
|
5107
|
-
const value = ManagedNeuronTrainingExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
5137
|
+
const value = ManagedNeuronTrainingExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5108
5138
|
const query = parseExecutionListQuery4(expected.query);
|
|
5109
|
-
if (
|
|
5139
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || expected.ownerUserId !== void 0 && value.ownerUserId !== expected.ownerUserId || canonicalJson(value.query) !== canonicalJson(query) || value.items.length > query.limit || new Set(value.items.map((item) => item.id)).size !== value.items.length) fail6();
|
|
5110
5140
|
for (const item of value.items) {
|
|
5111
5141
|
if (item.teamId !== value.teamId || item.ownerUserId !== value.ownerUserId || query.id !== void 0 && item.id !== query.id || query.projectId !== void 0 && item.projectId !== query.projectId || query.phase !== void 0 && item.phase !== query.phase || item.plan.maximumSpendUsd !== canonicalComputeSpendCap(item.plan.maximumSpendUsd) || Date.parse(item.plan.expiresAt) <= Date.parse(item.plan.createdAt)) fail6();
|
|
5112
5142
|
}
|
|
@@ -5152,18 +5182,18 @@ function createManagedNeuronTrainingExecutionClient(request) {
|
|
|
5152
5182
|
}
|
|
5153
5183
|
|
|
5154
5184
|
// src/alphaedit-model-serving.ts
|
|
5155
|
-
import { z as
|
|
5185
|
+
import { z as z45 } from "zod";
|
|
5156
5186
|
|
|
5157
5187
|
// src/weight-inference.ts
|
|
5158
|
-
import { z as
|
|
5159
|
-
var Id28 =
|
|
5160
|
-
var Hash33 =
|
|
5161
|
-
var SavedWeightModelSelectionSchema =
|
|
5162
|
-
var ResolvedWeightModelSelectionSchema =
|
|
5163
|
-
schemaVersion:
|
|
5164
|
-
method:
|
|
5188
|
+
import { z as z44 } from "zod";
|
|
5189
|
+
var Id28 = z44.string().trim().min(1).max(240);
|
|
5190
|
+
var Hash33 = z44.string().regex(/^[a-f0-9]{64}$/);
|
|
5191
|
+
var SavedWeightModelSelectionSchema = z44.object({ modelProjectId: Id28, versionHash: Hash33 }).strict();
|
|
5192
|
+
var ResolvedWeightModelSelectionSchema = z44.object({
|
|
5193
|
+
schemaVersion: z44.literal("openpond.resolvedWeightModelSelection.v1"),
|
|
5194
|
+
method: z44.enum(["alphaedit", "selective_neuron_training"]),
|
|
5165
5195
|
savedModel: SavedWeightModelSelectionSchema,
|
|
5166
|
-
artifact:
|
|
5196
|
+
artifact: z44.object({ id: Id28, contentHash: Hash33, manifestSha256: Hash33 }).strict(),
|
|
5167
5197
|
modelHash: Hash33
|
|
5168
5198
|
}).strict();
|
|
5169
5199
|
async function parseAndVerifyResolvedWeightModelSelection(raw, input) {
|
|
@@ -5174,97 +5204,97 @@ async function parseAndVerifyResolvedWeightModelSelection(raw, input) {
|
|
|
5174
5204
|
throw new OpenPondProtocolError("weight_model_selection_mismatch", "The admitted Model differs from its exact learned patch and base.");
|
|
5175
5205
|
return value;
|
|
5176
5206
|
}
|
|
5177
|
-
var WeightModelInferenceReceiptContentSchema =
|
|
5178
|
-
schemaVersion:
|
|
5207
|
+
var WeightModelInferenceReceiptContentSchema = z44.object({
|
|
5208
|
+
schemaVersion: z44.literal("openpond.weightModelInferenceReceipt.v1"),
|
|
5179
5209
|
teamId: Id28,
|
|
5180
5210
|
requestId: Id28,
|
|
5181
5211
|
requestHash: Hash33,
|
|
5182
5212
|
selection: ResolvedWeightModelSelectionSchema,
|
|
5183
5213
|
poolId: Id28,
|
|
5184
|
-
routingBinding:
|
|
5214
|
+
routingBinding: z44.object({ id: Id28, revision: z44.number().int().positive() }).strict(),
|
|
5185
5215
|
runtimeHash: Hash33,
|
|
5186
|
-
workerImageDigest:
|
|
5187
|
-
engineGeneration:
|
|
5216
|
+
workerImageDigest: z44.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5217
|
+
engineGeneration: z44.number().int().positive(),
|
|
5188
5218
|
cacheNamespace: Hash33,
|
|
5189
|
-
completedAt:
|
|
5219
|
+
completedAt: z44.iso.datetime()
|
|
5190
5220
|
}).strict();
|
|
5191
5221
|
var WeightModelInferenceReceiptSchema = WeightModelInferenceReceiptContentSchema.extend({ contentHash: Hash33 });
|
|
5192
5222
|
async function parseAndVerifyWeightModelInferenceReceipt(raw, expected) {
|
|
5193
|
-
const value = WeightModelInferenceReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5223
|
+
const value = WeightModelInferenceReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5194
5224
|
await parseAndVerifyResolvedWeightModelSelection(value.selection, expected.version);
|
|
5195
|
-
if (
|
|
5225
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.requestId !== expected.requestId || value.requestHash !== expected.requestHash || canonicalJson(value.selection) !== canonicalJson(expected.selection) || value.poolId !== expected.poolId || canonicalJson(value.routingBinding) !== canonicalJson(expected.routingBinding) || value.runtimeHash !== expected.runtimeHash || value.workerImageDigest !== expected.workerImageDigest || value.engineGeneration !== expected.engineGeneration || value.cacheNamespace !== expected.cacheNamespace)
|
|
5196
5226
|
throw new OpenPondProtocolError("weight_model_inference_mismatch", "The completed inference differs from its admitted Model, runtime or cache.");
|
|
5197
5227
|
return value;
|
|
5198
5228
|
}
|
|
5199
5229
|
|
|
5200
5230
|
// src/alphaedit-model-serving.ts
|
|
5201
|
-
var Id29 =
|
|
5202
|
-
var Hash34 =
|
|
5203
|
-
var BindingRef2 =
|
|
5204
|
-
var AlphaEditModelServingQuerySchema =
|
|
5205
|
-
var AlphaEditModelServingControlRequestSchema =
|
|
5231
|
+
var Id29 = z45.string().trim().min(1).max(240);
|
|
5232
|
+
var Hash34 = z45.string().regex(/^[a-f0-9]{64}$/);
|
|
5233
|
+
var BindingRef2 = z45.object({ id: Id29, revision: z45.number().int().positive() }).strict();
|
|
5234
|
+
var AlphaEditModelServingQuerySchema = z45.object({ teamId: Id29, versionHash: Hash34 }).strict();
|
|
5235
|
+
var AlphaEditModelServingControlRequestSchema = z45.object({
|
|
5206
5236
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5207
|
-
schemaVersion:
|
|
5237
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControlRequest.v1"),
|
|
5208
5238
|
teamId: Id29,
|
|
5209
5239
|
operationId: Id29,
|
|
5210
5240
|
versionHash: Hash34,
|
|
5211
|
-
expectedRevision:
|
|
5212
|
-
action:
|
|
5213
|
-
idleTimeoutSeconds:
|
|
5241
|
+
expectedRevision: z45.number().int().nonnegative(),
|
|
5242
|
+
action: z45.enum(["activate", "stop"]),
|
|
5243
|
+
idleTimeoutSeconds: z45.number().int().min(60).max(3600)
|
|
5214
5244
|
}).strict();
|
|
5215
5245
|
var AlphaEditModelServingControlIntentSchema = AlphaEditModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id29 }).strict();
|
|
5216
|
-
var AlphaEditModelServingControlCommandSchema =
|
|
5217
|
-
var AlphaEditModelServingControlSchema =
|
|
5246
|
+
var AlphaEditModelServingControlCommandSchema = z45.object({ modelProjectId: Id29, request: AlphaEditModelServingControlRequestSchema }).strict();
|
|
5247
|
+
var AlphaEditModelServingControlSchema = z45.object({
|
|
5218
5248
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5219
|
-
schemaVersion:
|
|
5249
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControl.v1"),
|
|
5220
5250
|
teamId: Id29,
|
|
5221
5251
|
modelProjectId: Id29,
|
|
5222
5252
|
versionHash: Hash34,
|
|
5223
5253
|
actorId: Id29,
|
|
5224
5254
|
operationId: Id29,
|
|
5225
|
-
revision:
|
|
5226
|
-
desiredState:
|
|
5227
|
-
phase:
|
|
5228
|
-
capacityState:
|
|
5229
|
-
modelId:
|
|
5255
|
+
revision: z45.number().int().positive(),
|
|
5256
|
+
desiredState: z45.enum(["active", "stopped"]),
|
|
5257
|
+
phase: z45.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5258
|
+
capacityState: z45.enum(["pending", "shared", "retiring", "released"]),
|
|
5259
|
+
modelId: z45.string().trim().min(1).max(500),
|
|
5230
5260
|
poolId: Id29.nullable(),
|
|
5231
5261
|
binding: BindingRef2.nullable(),
|
|
5232
|
-
activeRequests:
|
|
5233
|
-
unsettledRequests:
|
|
5234
|
-
idleTimeoutSeconds:
|
|
5262
|
+
activeRequests: z45.number().int().nonnegative(),
|
|
5263
|
+
unsettledRequests: z45.number().int().nonnegative(),
|
|
5264
|
+
idleTimeoutSeconds: z45.number().int().min(60).max(3600),
|
|
5235
5265
|
failureCode: Id29.nullable(),
|
|
5236
|
-
updatedAt:
|
|
5266
|
+
updatedAt: z45.iso.datetime()
|
|
5237
5267
|
}).strict();
|
|
5238
|
-
var AlphaEditServingBindingSchema =
|
|
5268
|
+
var AlphaEditServingBindingSchema = z45.object({
|
|
5239
5269
|
id: Id29,
|
|
5240
|
-
revision:
|
|
5241
|
-
modelId:
|
|
5270
|
+
revision: z45.number().int().positive(),
|
|
5271
|
+
modelId: z45.string().trim().min(1).max(500),
|
|
5242
5272
|
poolId: Id29,
|
|
5243
5273
|
versionHash: Hash34
|
|
5244
5274
|
}).strict();
|
|
5245
|
-
var AlphaEditServingAvailabilitySchema =
|
|
5246
|
-
state:
|
|
5247
|
-
reason:
|
|
5275
|
+
var AlphaEditServingAvailabilitySchema = z45.object({
|
|
5276
|
+
state: z45.enum(["qualified", "unavailable"]),
|
|
5277
|
+
reason: z45.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5248
5278
|
runtimeHash: Hash34.nullable()
|
|
5249
5279
|
}).strict();
|
|
5250
|
-
var AlphaEditModelServingContentSchema =
|
|
5280
|
+
var AlphaEditModelServingContentSchema = z45.object({
|
|
5251
5281
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5252
|
-
schemaVersion:
|
|
5282
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServing.v1"),
|
|
5253
5283
|
teamId: Id29,
|
|
5254
5284
|
modelProjectId: Id29,
|
|
5255
|
-
observedAt:
|
|
5285
|
+
observedAt: z45.iso.datetime(),
|
|
5256
5286
|
version: AlphaEditModelVersionSchema,
|
|
5257
5287
|
availability: AlphaEditServingAvailabilitySchema,
|
|
5258
5288
|
control: AlphaEditModelServingControlSchema.nullable(),
|
|
5259
|
-
cleanup:
|
|
5260
|
-
pools:
|
|
5261
|
-
bindings:
|
|
5289
|
+
cleanup: z45.array(AlphaEditModelServingControlSchema).max(100),
|
|
5290
|
+
pools: z45.array(TrainingServingPoolSchema).max(100),
|
|
5291
|
+
bindings: z45.array(AlphaEditServingBindingSchema).max(100),
|
|
5262
5292
|
lastVerifiedInference: WeightModelInferenceReceiptSchema.nullable(),
|
|
5263
|
-
state:
|
|
5293
|
+
state: z45.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5264
5294
|
}).strict();
|
|
5265
5295
|
var AlphaEditModelServingSchema = AlphaEditModelServingContentSchema.extend({ contentHash: Hash34 });
|
|
5266
|
-
var AlphaEditModelServingControlReceiptContentSchema =
|
|
5267
|
-
schemaVersion:
|
|
5296
|
+
var AlphaEditModelServingControlReceiptContentSchema = z45.object({
|
|
5297
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControlReceipt.v1"),
|
|
5268
5298
|
teamId: Id29,
|
|
5269
5299
|
modelProjectId: Id29,
|
|
5270
5300
|
actorId: Id29,
|
|
@@ -5287,24 +5317,24 @@ function alphaEditModelServingState(value) {
|
|
|
5287
5317
|
}
|
|
5288
5318
|
async function parseAndVerifyAlphaEditModelServingControl(raw, expected) {
|
|
5289
5319
|
const value = AlphaEditModelServingControlReceiptSchema.parse(raw), request = AlphaEditModelServingControlRequestSchema.parse(expected.request);
|
|
5290
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5320
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5291
5321
|
await parseAndVerifyAlphaEditModelVersion(value.version, {
|
|
5292
5322
|
teamId: request.teamId,
|
|
5293
5323
|
modelProjectId: expected.modelProjectId,
|
|
5294
5324
|
ownerUserId: value.actorId
|
|
5295
5325
|
});
|
|
5296
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5326
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || canonicalJson(value.request) !== canonicalJson(request) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || expected.actorId !== void 0 && value.actorId !== expected.actorId || value.version.contentHash !== request.versionHash || control2.teamId !== value.teamId || control2.modelProjectId !== value.modelProjectId || control2.actorId !== value.actorId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || !validControl2(control2) || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
5297
5327
|
throw new OpenPondProtocolError("alphaedit_serving_control_mismatch", "The serving receipt differs from the exact AlphaEdit Model or original control command.");
|
|
5298
5328
|
return value;
|
|
5299
5329
|
}
|
|
5300
5330
|
async function parseAndVerifyAlphaEditModelServing(raw, expected) {
|
|
5301
|
-
const value = AlphaEditModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5331
|
+
const value = AlphaEditModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5302
5332
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "alphaedit" }, value.control);
|
|
5303
5333
|
await parseAndVerifyAlphaEditModelVersion(value.version, expected);
|
|
5304
5334
|
function fail8() {
|
|
5305
5335
|
throw new OpenPondProtocolError("alphaedit_model_serving_mismatch", "The serving evidence differs from the exact AlphaEdit Model or retained resource custody.");
|
|
5306
5336
|
}
|
|
5307
|
-
if (
|
|
5337
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || value.state !== alphaEditModelServingState(value) || value.availability.state === "qualified" !== (value.availability.reason === "qualified") || value.availability.state === "qualified" && value.availability.runtimeHash === null) fail8();
|
|
5308
5338
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5309
5339
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5310
5340
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl2(control3)) fail8();
|
|
@@ -5345,74 +5375,74 @@ function createAlphaEditModelServingClient(request) {
|
|
|
5345
5375
|
}
|
|
5346
5376
|
|
|
5347
5377
|
// src/neuron-training-model-serving.ts
|
|
5348
|
-
import { z as
|
|
5349
|
-
var Id30 =
|
|
5350
|
-
var Hash35 =
|
|
5351
|
-
var BindingRef3 =
|
|
5352
|
-
var NeuronTrainingModelServingQuerySchema =
|
|
5353
|
-
var NeuronTrainingModelServingControlRequestSchema =
|
|
5378
|
+
import { z as z46 } from "zod";
|
|
5379
|
+
var Id30 = z46.string().trim().min(1).max(240);
|
|
5380
|
+
var Hash35 = z46.string().regex(/^[a-f0-9]{64}$/);
|
|
5381
|
+
var BindingRef3 = z46.object({ id: Id30, revision: z46.number().int().positive() }).strict();
|
|
5382
|
+
var NeuronTrainingModelServingQuerySchema = z46.object({ teamId: Id30, versionHash: Hash35 }).strict();
|
|
5383
|
+
var NeuronTrainingModelServingControlRequestSchema = z46.object({
|
|
5354
5384
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5355
|
-
schemaVersion:
|
|
5385
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControlRequest.v1"),
|
|
5356
5386
|
teamId: Id30,
|
|
5357
5387
|
operationId: Id30,
|
|
5358
5388
|
versionHash: Hash35,
|
|
5359
|
-
expectedRevision:
|
|
5360
|
-
action:
|
|
5361
|
-
idleTimeoutSeconds:
|
|
5389
|
+
expectedRevision: z46.number().int().nonnegative(),
|
|
5390
|
+
action: z46.enum(["activate", "stop"]),
|
|
5391
|
+
idleTimeoutSeconds: z46.number().int().min(60).max(3600)
|
|
5362
5392
|
}).strict();
|
|
5363
5393
|
var NeuronTrainingModelServingControlIntentSchema = NeuronTrainingModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id30 }).strict();
|
|
5364
|
-
var NeuronTrainingModelServingControlCommandSchema =
|
|
5365
|
-
var NeuronTrainingModelServingControlSchema =
|
|
5394
|
+
var NeuronTrainingModelServingControlCommandSchema = z46.object({ modelProjectId: Id30, request: NeuronTrainingModelServingControlRequestSchema }).strict();
|
|
5395
|
+
var NeuronTrainingModelServingControlSchema = z46.object({
|
|
5366
5396
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5367
|
-
schemaVersion:
|
|
5397
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControl.v1"),
|
|
5368
5398
|
teamId: Id30,
|
|
5369
5399
|
modelProjectId: Id30,
|
|
5370
5400
|
versionHash: Hash35,
|
|
5371
5401
|
actorId: Id30,
|
|
5372
5402
|
operationId: Id30,
|
|
5373
|
-
revision:
|
|
5374
|
-
desiredState:
|
|
5375
|
-
phase:
|
|
5376
|
-
capacityState:
|
|
5377
|
-
modelId:
|
|
5403
|
+
revision: z46.number().int().positive(),
|
|
5404
|
+
desiredState: z46.enum(["active", "stopped"]),
|
|
5405
|
+
phase: z46.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5406
|
+
capacityState: z46.enum(["pending", "shared", "retiring", "released"]),
|
|
5407
|
+
modelId: z46.string().trim().min(1).max(500),
|
|
5378
5408
|
poolId: Id30.nullable(),
|
|
5379
5409
|
binding: BindingRef3.nullable(),
|
|
5380
|
-
activeRequests:
|
|
5381
|
-
unsettledRequests:
|
|
5382
|
-
idleTimeoutSeconds:
|
|
5410
|
+
activeRequests: z46.number().int().nonnegative(),
|
|
5411
|
+
unsettledRequests: z46.number().int().nonnegative(),
|
|
5412
|
+
idleTimeoutSeconds: z46.number().int().min(60).max(3600),
|
|
5383
5413
|
failureCode: Id30.nullable(),
|
|
5384
|
-
updatedAt:
|
|
5414
|
+
updatedAt: z46.iso.datetime()
|
|
5385
5415
|
}).strict();
|
|
5386
|
-
var NeuronTrainingServingBindingSchema =
|
|
5416
|
+
var NeuronTrainingServingBindingSchema = z46.object({
|
|
5387
5417
|
id: Id30,
|
|
5388
|
-
revision:
|
|
5389
|
-
modelId:
|
|
5418
|
+
revision: z46.number().int().positive(),
|
|
5419
|
+
modelId: z46.string().trim().min(1).max(500),
|
|
5390
5420
|
poolId: Id30,
|
|
5391
5421
|
versionHash: Hash35
|
|
5392
5422
|
}).strict();
|
|
5393
|
-
var NeuronTrainingServingAvailabilitySchema =
|
|
5394
|
-
state:
|
|
5395
|
-
reason:
|
|
5423
|
+
var NeuronTrainingServingAvailabilitySchema = z46.object({
|
|
5424
|
+
state: z46.enum(["qualified", "unavailable"]),
|
|
5425
|
+
reason: z46.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5396
5426
|
runtimeHash: Hash35.nullable()
|
|
5397
5427
|
}).strict();
|
|
5398
|
-
var NeuronTrainingModelServingContentSchema =
|
|
5428
|
+
var NeuronTrainingModelServingContentSchema = z46.object({
|
|
5399
5429
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5400
|
-
schemaVersion:
|
|
5430
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServing.v1"),
|
|
5401
5431
|
teamId: Id30,
|
|
5402
5432
|
modelProjectId: Id30,
|
|
5403
|
-
observedAt:
|
|
5433
|
+
observedAt: z46.iso.datetime(),
|
|
5404
5434
|
version: NeuronTrainingModelVersionSchema,
|
|
5405
5435
|
availability: NeuronTrainingServingAvailabilitySchema,
|
|
5406
5436
|
control: NeuronTrainingModelServingControlSchema.nullable(),
|
|
5407
|
-
cleanup:
|
|
5408
|
-
pools:
|
|
5409
|
-
bindings:
|
|
5437
|
+
cleanup: z46.array(NeuronTrainingModelServingControlSchema).max(100),
|
|
5438
|
+
pools: z46.array(TrainingServingPoolSchema).max(100),
|
|
5439
|
+
bindings: z46.array(NeuronTrainingServingBindingSchema).max(100),
|
|
5410
5440
|
lastVerifiedInference: WeightModelInferenceReceiptSchema.nullable(),
|
|
5411
|
-
state:
|
|
5441
|
+
state: z46.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5412
5442
|
}).strict();
|
|
5413
5443
|
var NeuronTrainingModelServingSchema = NeuronTrainingModelServingContentSchema.extend({ contentHash: Hash35 });
|
|
5414
|
-
var NeuronTrainingModelServingControlReceiptContentSchema =
|
|
5415
|
-
schemaVersion:
|
|
5444
|
+
var NeuronTrainingModelServingControlReceiptContentSchema = z46.object({
|
|
5445
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControlReceipt.v1"),
|
|
5416
5446
|
teamId: Id30,
|
|
5417
5447
|
modelProjectId: Id30,
|
|
5418
5448
|
actorId: Id30,
|
|
@@ -5435,24 +5465,24 @@ function neuronTrainingModelServingState(value) {
|
|
|
5435
5465
|
}
|
|
5436
5466
|
async function parseAndVerifyNeuronTrainingModelServingControl(raw, expected) {
|
|
5437
5467
|
const value = NeuronTrainingModelServingControlReceiptSchema.parse(raw), request = NeuronTrainingModelServingControlRequestSchema.parse(expected.request);
|
|
5438
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5468
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5439
5469
|
await parseAndVerifyNeuronTrainingModelVersion(value.version, {
|
|
5440
5470
|
teamId: request.teamId,
|
|
5441
5471
|
modelProjectId: expected.modelProjectId,
|
|
5442
5472
|
ownerUserId: value.actorId
|
|
5443
5473
|
});
|
|
5444
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5474
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || canonicalJson(value.request) !== canonicalJson(request) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || expected.actorId !== void 0 && value.actorId !== expected.actorId || value.version.contentHash !== request.versionHash || control2.teamId !== value.teamId || control2.modelProjectId !== value.modelProjectId || control2.actorId !== value.actorId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || !validControl3(control2) || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
5445
5475
|
throw new OpenPondProtocolError("neuron_training_serving_control_mismatch", "The serving receipt differs from the exact neuron-training Model or original control command.");
|
|
5446
5476
|
return value;
|
|
5447
5477
|
}
|
|
5448
5478
|
async function parseAndVerifyNeuronTrainingModelServing(raw, expected) {
|
|
5449
|
-
const value = NeuronTrainingModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5479
|
+
const value = NeuronTrainingModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5450
5480
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "selective_neuron_training" }, value.control);
|
|
5451
5481
|
await parseAndVerifyNeuronTrainingModelVersion(value.version, expected);
|
|
5452
5482
|
function fail8() {
|
|
5453
5483
|
throw new OpenPondProtocolError("neuron_training_model_serving_mismatch", "The serving evidence differs from the exact neuron-training Model or retained resource custody.");
|
|
5454
5484
|
}
|
|
5455
|
-
if (
|
|
5485
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || value.state !== neuronTrainingModelServingState(value) || value.availability.state === "qualified" !== (value.availability.reason === "qualified") || value.availability.state === "qualified" && value.availability.runtimeHash === null) fail8();
|
|
5456
5486
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5457
5487
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5458
5488
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl3(control3)) fail8();
|
|
@@ -5493,20 +5523,20 @@ function createNeuronTrainingModelServingClient(request) {
|
|
|
5493
5523
|
}
|
|
5494
5524
|
|
|
5495
5525
|
// src/decision-model-scoring.ts
|
|
5496
|
-
import { z as
|
|
5526
|
+
import { z as z47 } from "zod";
|
|
5497
5527
|
import { assertBoundedTaskJson as assertBoundedTaskJson8 } from "@openpond/evals/task-schema";
|
|
5498
|
-
var Id31 =
|
|
5499
|
-
var Hash36 =
|
|
5500
|
-
var Binding =
|
|
5501
|
-
var SavedDecisionModelSelectionSchema =
|
|
5502
|
-
var ResolvedDecisionSelectionSchema =
|
|
5503
|
-
schemaVersion:
|
|
5528
|
+
var Id31 = z47.string().trim().min(1).max(240);
|
|
5529
|
+
var Hash36 = z47.string().regex(/^[a-f0-9]{64}$/);
|
|
5530
|
+
var Binding = z47.object({ id: Id31, revision: z47.number().int().positive() }).strict();
|
|
5531
|
+
var SavedDecisionModelSelectionSchema = z47.object({ modelProjectId: Id31, versionHash: Hash36 }).strict();
|
|
5532
|
+
var ResolvedDecisionSelectionSchema = z47.object({
|
|
5533
|
+
schemaVersion: z47.literal("openpond.resolvedDecisionSelection.v1"),
|
|
5504
5534
|
savedModel: SavedDecisionModelSelectionSchema,
|
|
5505
5535
|
modelHash: Hash36,
|
|
5506
|
-
artifact:
|
|
5536
|
+
artifact: z47.object({ id: Id31, contentHash: Hash36, payloadSha256: Hash36 }).strict()
|
|
5507
5537
|
}).strict();
|
|
5508
|
-
var DecisionModelScoreRequestSchema =
|
|
5509
|
-
schemaVersion:
|
|
5538
|
+
var DecisionModelScoreRequestSchema = z47.object({
|
|
5539
|
+
schemaVersion: z47.literal("openpond.decisionModelScoreRequest.v1"),
|
|
5510
5540
|
teamId: Id31,
|
|
5511
5541
|
requestId: Id31,
|
|
5512
5542
|
versionHash: Hash36,
|
|
@@ -5536,8 +5566,8 @@ async function parseAndVerifyResolvedDecisionSelection(raw, version) {
|
|
|
5536
5566
|
throw new OpenPondProtocolError("decision_selection_mismatch", "The scorer selected a different exact decision Model or adapter.");
|
|
5537
5567
|
return value;
|
|
5538
5568
|
}
|
|
5539
|
-
var DecisionModelScoreReceiptContentSchema =
|
|
5540
|
-
schemaVersion:
|
|
5569
|
+
var DecisionModelScoreReceiptContentSchema = z47.object({
|
|
5570
|
+
schemaVersion: z47.literal("openpond.decisionModelScoreReceipt.v1"),
|
|
5541
5571
|
teamId: Id31,
|
|
5542
5572
|
actorId: Id31,
|
|
5543
5573
|
modelProjectId: Id31,
|
|
@@ -5549,17 +5579,17 @@ var DecisionModelScoreReceiptContentSchema = z46.object({
|
|
|
5549
5579
|
poolId: Id31,
|
|
5550
5580
|
routingBinding: Binding,
|
|
5551
5581
|
runtimeHash: Hash36,
|
|
5552
|
-
workerImageDigest:
|
|
5553
|
-
engineGeneration:
|
|
5582
|
+
workerImageDigest: z47.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5583
|
+
engineGeneration: z47.number().int().positive(),
|
|
5554
5584
|
cacheNamespace: Hash36,
|
|
5555
|
-
cleanupComplete:
|
|
5556
|
-
completedAt:
|
|
5585
|
+
cleanupComplete: z47.literal(true),
|
|
5586
|
+
completedAt: z47.iso.datetime()
|
|
5557
5587
|
}).strict();
|
|
5558
5588
|
var DecisionModelScoreReceiptSchema = DecisionModelScoreReceiptContentSchema.extend({ contentHash: Hash36 });
|
|
5559
5589
|
async function parseAndVerifyDecisionModelScoreReceipt(raw, expected) {
|
|
5560
5590
|
assertBoundedTaskJson8(raw, 1048576);
|
|
5561
5591
|
const request = parseDecisionModelScoreRequest(expected.request);
|
|
5562
|
-
const value = DecisionModelScoreReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5592
|
+
const value = DecisionModelScoreReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5563
5593
|
const version = await parseAndVerifyDecisionModelVersion(value.version, {
|
|
5564
5594
|
teamId: request.teamId,
|
|
5565
5595
|
modelProjectId: expected.modelProjectId,
|
|
@@ -5578,7 +5608,7 @@ async function parseAndVerifyDecisionModelScoreReceipt(raw, expected) {
|
|
|
5578
5608
|
function fail8() {
|
|
5579
5609
|
throw new OpenPondProtocolError("decision_model_score_mismatch", "The completed score differs from the exact Model, original request or admitted runtime.");
|
|
5580
5610
|
}
|
|
5581
|
-
if (
|
|
5611
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || value.requestId !== request.requestId || expected.actorId !== void 0 && value.actorId !== expected.actorId || value.requestHash !== await canonicalSha256({ modelProjectId: expected.modelProjectId, request })) fail8();
|
|
5582
5612
|
const admission = expected.admission;
|
|
5583
5613
|
if (admission && (value.poolId !== admission.poolId || canonicalJson(value.routingBinding) !== canonicalJson(admission.routingBinding) || value.runtimeHash !== admission.runtimeHash || value.workerImageDigest !== admission.workerImageDigest || admission.engineGeneration !== void 0 && value.engineGeneration !== admission.engineGeneration || admission.cacheNamespace !== void 0 && value.cacheNamespace !== admission.cacheNamespace)) fail8();
|
|
5584
5614
|
return value;
|
|
@@ -5597,74 +5627,74 @@ function createDecisionModelScoringClient(request) {
|
|
|
5597
5627
|
}
|
|
5598
5628
|
|
|
5599
5629
|
// src/decision-model-serving.ts
|
|
5600
|
-
import { z as
|
|
5601
|
-
var Id32 =
|
|
5602
|
-
var Hash37 =
|
|
5603
|
-
var BindingRef4 =
|
|
5604
|
-
var DecisionModelServingQuerySchema =
|
|
5605
|
-
var DecisionModelServingControlRequestSchema =
|
|
5630
|
+
import { z as z48 } from "zod";
|
|
5631
|
+
var Id32 = z48.string().trim().min(1).max(240);
|
|
5632
|
+
var Hash37 = z48.string().regex(/^[a-f0-9]{64}$/);
|
|
5633
|
+
var BindingRef4 = z48.object({ id: Id32, revision: z48.number().int().positive() }).strict();
|
|
5634
|
+
var DecisionModelServingQuerySchema = z48.object({ teamId: Id32, versionHash: Hash37 }).strict();
|
|
5635
|
+
var DecisionModelServingControlRequestSchema = z48.object({
|
|
5606
5636
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5607
|
-
schemaVersion:
|
|
5637
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControlRequest.v1"),
|
|
5608
5638
|
teamId: Id32,
|
|
5609
5639
|
operationId: Id32,
|
|
5610
5640
|
versionHash: Hash37,
|
|
5611
|
-
expectedRevision:
|
|
5612
|
-
action:
|
|
5613
|
-
idleTimeoutSeconds:
|
|
5641
|
+
expectedRevision: z48.number().int().nonnegative(),
|
|
5642
|
+
action: z48.enum(["activate", "stop"]),
|
|
5643
|
+
idleTimeoutSeconds: z48.number().int().min(60).max(3600)
|
|
5614
5644
|
}).strict();
|
|
5615
5645
|
var DecisionModelServingControlIntentSchema = DecisionModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id32 }).strict();
|
|
5616
|
-
var DecisionModelServingControlCommandSchema =
|
|
5617
|
-
var DecisionModelServingControlSchema =
|
|
5646
|
+
var DecisionModelServingControlCommandSchema = z48.object({ modelProjectId: Id32, request: DecisionModelServingControlRequestSchema }).strict();
|
|
5647
|
+
var DecisionModelServingControlSchema = z48.object({
|
|
5618
5648
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5619
|
-
schemaVersion:
|
|
5649
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControl.v1"),
|
|
5620
5650
|
teamId: Id32,
|
|
5621
5651
|
modelProjectId: Id32,
|
|
5622
5652
|
versionHash: Hash37,
|
|
5623
5653
|
actorId: Id32,
|
|
5624
5654
|
operationId: Id32,
|
|
5625
|
-
revision:
|
|
5626
|
-
desiredState:
|
|
5627
|
-
phase:
|
|
5628
|
-
capacityState:
|
|
5629
|
-
modelId:
|
|
5655
|
+
revision: z48.number().int().positive(),
|
|
5656
|
+
desiredState: z48.enum(["active", "stopped"]),
|
|
5657
|
+
phase: z48.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5658
|
+
capacityState: z48.enum(["pending", "shared", "retiring", "released"]),
|
|
5659
|
+
modelId: z48.string().trim().min(1).max(500),
|
|
5630
5660
|
poolId: Id32.nullable(),
|
|
5631
5661
|
binding: BindingRef4.nullable(),
|
|
5632
|
-
activeRequests:
|
|
5633
|
-
unsettledRequests:
|
|
5634
|
-
idleTimeoutSeconds:
|
|
5662
|
+
activeRequests: z48.number().int().nonnegative(),
|
|
5663
|
+
unsettledRequests: z48.number().int().nonnegative(),
|
|
5664
|
+
idleTimeoutSeconds: z48.number().int().min(60).max(3600),
|
|
5635
5665
|
failureCode: Id32.nullable(),
|
|
5636
|
-
updatedAt:
|
|
5666
|
+
updatedAt: z48.iso.datetime()
|
|
5637
5667
|
}).strict();
|
|
5638
|
-
var DecisionServingBindingSchema =
|
|
5668
|
+
var DecisionServingBindingSchema = z48.object({
|
|
5639
5669
|
id: Id32,
|
|
5640
|
-
revision:
|
|
5641
|
-
modelId:
|
|
5670
|
+
revision: z48.number().int().positive(),
|
|
5671
|
+
modelId: z48.string().trim().min(1).max(500),
|
|
5642
5672
|
poolId: Id32,
|
|
5643
5673
|
versionHash: Hash37
|
|
5644
5674
|
}).strict();
|
|
5645
|
-
var DecisionServingAvailabilitySchema =
|
|
5646
|
-
state:
|
|
5647
|
-
reason:
|
|
5675
|
+
var DecisionServingAvailabilitySchema = z48.object({
|
|
5676
|
+
state: z48.enum(["qualified", "unavailable"]),
|
|
5677
|
+
reason: z48.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5648
5678
|
runtimeHash: Hash37.nullable()
|
|
5649
5679
|
}).strict();
|
|
5650
|
-
var DecisionModelServingContentSchema =
|
|
5680
|
+
var DecisionModelServingContentSchema = z48.object({
|
|
5651
5681
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5652
|
-
schemaVersion:
|
|
5682
|
+
schemaVersion: z48.literal("openpond.decisionModelServing.v1"),
|
|
5653
5683
|
teamId: Id32,
|
|
5654
5684
|
modelProjectId: Id32,
|
|
5655
|
-
observedAt:
|
|
5685
|
+
observedAt: z48.iso.datetime(),
|
|
5656
5686
|
version: DecisionModelVersionSchema,
|
|
5657
5687
|
availability: DecisionServingAvailabilitySchema,
|
|
5658
5688
|
control: DecisionModelServingControlSchema.nullable(),
|
|
5659
|
-
cleanup:
|
|
5660
|
-
pools:
|
|
5661
|
-
bindings:
|
|
5689
|
+
cleanup: z48.array(DecisionModelServingControlSchema).max(100),
|
|
5690
|
+
pools: z48.array(TrainingServingPoolSchema).max(100),
|
|
5691
|
+
bindings: z48.array(DecisionServingBindingSchema).max(100),
|
|
5662
5692
|
lastVerifiedScore: DecisionModelScoreReceiptSchema.nullable(),
|
|
5663
|
-
state:
|
|
5693
|
+
state: z48.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5664
5694
|
}).strict();
|
|
5665
5695
|
var DecisionModelServingSchema = DecisionModelServingContentSchema.extend({ contentHash: Hash37 });
|
|
5666
|
-
var DecisionModelServingControlReceiptContentSchema =
|
|
5667
|
-
schemaVersion:
|
|
5696
|
+
var DecisionModelServingControlReceiptContentSchema = z48.object({
|
|
5697
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControlReceipt.v1"),
|
|
5668
5698
|
teamId: Id32,
|
|
5669
5699
|
modelProjectId: Id32,
|
|
5670
5700
|
actorId: Id32,
|
|
@@ -5687,25 +5717,25 @@ function decisionModelServingState(value) {
|
|
|
5687
5717
|
}
|
|
5688
5718
|
async function parseAndVerifyDecisionModelServingControl(raw, expected) {
|
|
5689
5719
|
const value = DecisionModelServingControlReceiptSchema.parse(raw), request = DecisionModelServingControlRequestSchema.parse(expected.request);
|
|
5690
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5720
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5691
5721
|
await parseAndVerifyDecisionModelVersion(value.version, {
|
|
5692
5722
|
teamId: request.teamId,
|
|
5693
5723
|
modelProjectId: expected.modelProjectId,
|
|
5694
5724
|
ownerUserId: value.actorId,
|
|
5695
5725
|
versionHash: request.versionHash
|
|
5696
5726
|
});
|
|
5697
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5727
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || canonicalJson(value.request) !== canonicalJson(request) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || expected.actorId !== void 0 && value.actorId !== expected.actorId || control2.teamId !== value.teamId || control2.modelProjectId !== value.modelProjectId || control2.actorId !== value.actorId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || !validControl4(control2) || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
5698
5728
|
throw new OpenPondProtocolError("decision_serving_control_mismatch", "The serving receipt differs from the exact decision Model or original control command.");
|
|
5699
5729
|
return value;
|
|
5700
5730
|
}
|
|
5701
5731
|
async function parseAndVerifyDecisionModelServing(raw, expected) {
|
|
5702
|
-
const value = DecisionModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5732
|
+
const value = DecisionModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5703
5733
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "decision" }, value.control);
|
|
5704
5734
|
await parseAndVerifyDecisionModelVersion(value.version, expected);
|
|
5705
5735
|
function fail8() {
|
|
5706
5736
|
throw new OpenPondProtocolError("decision_model_serving_mismatch", "The serving evidence differs from the exact decision Model or retained resource custody.");
|
|
5707
5737
|
}
|
|
5708
|
-
if (
|
|
5738
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.state !== decisionModelServingState(value) || value.availability.state === "qualified" !== (value.availability.reason === "qualified") || value.availability.state === "qualified" && value.availability.runtimeHash === null) fail8();
|
|
5709
5739
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5710
5740
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5711
5741
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl4(control3)) fail8();
|
|
@@ -5856,30 +5886,30 @@ async function engramFormFromModelVersion(form, raw, expected = {}) {
|
|
|
5856
5886
|
}
|
|
5857
5887
|
|
|
5858
5888
|
// src/training-executions.ts
|
|
5859
|
-
import { z as
|
|
5860
|
-
var Id33 =
|
|
5861
|
-
var TrainingExecutionSummarySchema =
|
|
5862
|
-
schemaVersion:
|
|
5863
|
-
job:
|
|
5864
|
-
name:
|
|
5865
|
-
method:
|
|
5866
|
-
model:
|
|
5889
|
+
import { z as z49 } from "zod";
|
|
5890
|
+
var Id33 = z49.string().trim().min(1).max(500);
|
|
5891
|
+
var TrainingExecutionSummarySchema = z49.object({
|
|
5892
|
+
schemaVersion: z49.literal("openpond.trainingExecutionSummary.v1"),
|
|
5893
|
+
job: z49.lazy(() => TrainingJobSchema),
|
|
5894
|
+
name: z49.string().min(1).max(500),
|
|
5895
|
+
method: z49.enum(["sft", "grpo", "reward_model_train"]).nullable(),
|
|
5896
|
+
model: z49.object({ modelId: Id33, revision: Id33.nullable() }).strict().nullable(),
|
|
5867
5897
|
dataset: ModelProjectVersionedRefSchema.nullable(),
|
|
5868
|
-
startedAt:
|
|
5898
|
+
startedAt: z49.iso.datetime().nullable()
|
|
5869
5899
|
}).strict();
|
|
5870
|
-
var TrainingExecutionListQuerySchema =
|
|
5900
|
+
var TrainingExecutionListQuerySchema = z49.object({
|
|
5871
5901
|
projectId: Id33.optional(),
|
|
5872
|
-
datasetHash:
|
|
5873
|
-
search:
|
|
5874
|
-
cursor:
|
|
5875
|
-
limit:
|
|
5902
|
+
datasetHash: z49.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
5903
|
+
search: z49.string().trim().max(1e3).optional(),
|
|
5904
|
+
cursor: z49.string().trim().min(1).max(2e3).optional(),
|
|
5905
|
+
limit: z49.number().int().min(1).max(100).default(30)
|
|
5876
5906
|
}).strict();
|
|
5877
|
-
var TrainingExecutionPageSchema =
|
|
5878
|
-
schemaVersion:
|
|
5907
|
+
var TrainingExecutionPageSchema = z49.object({
|
|
5908
|
+
schemaVersion: z49.literal("openpond.trainingExecutionPage.v1"),
|
|
5879
5909
|
teamId: Id33,
|
|
5880
5910
|
projectId: Id33.nullable(),
|
|
5881
|
-
items:
|
|
5882
|
-
nextCursor:
|
|
5911
|
+
items: z49.array(TrainingExecutionSummarySchema).max(100),
|
|
5912
|
+
nextCursor: z49.string().trim().min(1).max(2e3).nullable()
|
|
5883
5913
|
}).strict();
|
|
5884
5914
|
function createTrainingExecutionClient(request) {
|
|
5885
5915
|
return {
|
|
@@ -5903,10 +5933,10 @@ function createTrainingExecutionClient(request) {
|
|
|
5903
5933
|
}
|
|
5904
5934
|
|
|
5905
5935
|
// src/training-acceptance.ts
|
|
5906
|
-
import { z as
|
|
5936
|
+
import { z as z50 } from "zod";
|
|
5907
5937
|
import { assertAcceptanceGroupSnapshot, AcceptanceGroupSnapshotSchema } from "@openpond/evals/learning";
|
|
5908
|
-
var Id34 =
|
|
5909
|
-
var TrainingAcceptanceGroupReferenceSchema = ModelProjectImmutableRefSchema.extend({ revision:
|
|
5938
|
+
var Id34 = z50.string().trim().min(1).max(240);
|
|
5939
|
+
var TrainingAcceptanceGroupReferenceSchema = ModelProjectImmutableRefSchema.extend({ revision: z50.number().int().positive() }).strict();
|
|
5910
5940
|
var TrainingAcceptanceGroupSummarySchema = TrainingAcceptanceGroupReferenceSchema.extend({
|
|
5911
5941
|
teamId: Id34,
|
|
5912
5942
|
jobId: Id34,
|
|
@@ -5914,18 +5944,18 @@ var TrainingAcceptanceGroupSummarySchema = TrainingAcceptanceGroupReferenceSchem
|
|
|
5914
5944
|
baseline: ModelProjectImmutableRefSchema,
|
|
5915
5945
|
candidate: ModelProjectImmutableRefSchema,
|
|
5916
5946
|
state: AcceptanceGroupSnapshotSchema.shape.state,
|
|
5917
|
-
updatedAt:
|
|
5947
|
+
updatedAt: z50.string().datetime()
|
|
5918
5948
|
}).strict();
|
|
5919
|
-
var TrainingAcceptanceGroupPageSchema =
|
|
5920
|
-
schemaVersion:
|
|
5949
|
+
var TrainingAcceptanceGroupPageSchema = z50.object({
|
|
5950
|
+
schemaVersion: z50.literal("openpond.trainingAcceptanceGroupPage.v1"),
|
|
5921
5951
|
teamId: Id34,
|
|
5922
5952
|
jobId: Id34,
|
|
5923
|
-
groups:
|
|
5953
|
+
groups: z50.array(TrainingAcceptanceGroupSummarySchema).max(100),
|
|
5924
5954
|
nextCursor: Id34.nullable()
|
|
5925
5955
|
}).strict();
|
|
5926
|
-
var TrainingAcceptanceGroupQuerySchema =
|
|
5956
|
+
var TrainingAcceptanceGroupQuerySchema = z50.object({
|
|
5927
5957
|
cursor: Id34.optional(),
|
|
5928
|
-
limit:
|
|
5958
|
+
limit: z50.number().int().min(1).max(100).default(25)
|
|
5929
5959
|
}).strict();
|
|
5930
5960
|
function createTrainingAcceptanceClient(request) {
|
|
5931
5961
|
const route = (target) => {
|
|
@@ -5955,21 +5985,111 @@ function createTrainingAcceptanceClient(request) {
|
|
|
5955
5985
|
}
|
|
5956
5986
|
|
|
5957
5987
|
// src/training.ts
|
|
5958
|
-
import { z as
|
|
5988
|
+
import { z as z67 } from "zod";
|
|
5959
5989
|
|
|
5960
|
-
// src/training-
|
|
5990
|
+
// src/training-experiment-learning.ts
|
|
5961
5991
|
import { z as z51 } from "zod";
|
|
5992
|
+
import { LearningRevisionRefSchema as LearningRevisionRefSchema3 } from "@openpond/evals/learning";
|
|
5993
|
+
var TrainingExperimentLearningRequestSchema = z51.object({
|
|
5994
|
+
schemaVersion: z51.literal("openpond.trainingExperimentLearning.v1"),
|
|
5995
|
+
teamId: z51.string().min(1).max(191),
|
|
5996
|
+
projectId: z51.string().min(1).max(191).nullable(),
|
|
5997
|
+
draftId: z51.string().min(1).max(191),
|
|
5998
|
+
form: TrainingExperimentFormDraftSchema.omit({ learningConfiguration: true }),
|
|
5999
|
+
expectedConfiguration: TrainingPreparationRequestSchema.shape.configuration.optional(),
|
|
6000
|
+
expectedPolicy: LearningRevisionRefSchema3.optional()
|
|
6001
|
+
}).strict();
|
|
6002
|
+
var TrainingExperimentLearningReceiptSchema = z51.object({
|
|
6003
|
+
schemaVersion: z51.literal("openpond.trainingExperimentLearningReceipt.v1"),
|
|
6004
|
+
inputHash: z51.string().regex(/^[a-f0-9]{64}$/),
|
|
6005
|
+
configuration: HostedModelProjectSummarySchema,
|
|
6006
|
+
policy: LearningRevisionRefSchema3
|
|
6007
|
+
}).strict();
|
|
6008
|
+
function trainingExperimentLearningRequest(input) {
|
|
6009
|
+
const { learningConfiguration, ...form } = input.form;
|
|
6010
|
+
const saved = learningConfiguration?.configuration;
|
|
6011
|
+
return TrainingExperimentLearningRequestSchema.parse({
|
|
6012
|
+
schemaVersion: "openpond.trainingExperimentLearning.v1",
|
|
6013
|
+
...input,
|
|
6014
|
+
form,
|
|
6015
|
+
...saved ? { expectedConfiguration: { id: saved.id, expectedRevision: saved.revision, expectedEtag: saved.etag }, expectedPolicy: learningConfiguration.policy } : {}
|
|
6016
|
+
});
|
|
6017
|
+
}
|
|
6018
|
+
async function trainingExperimentLearningInputHash(input) {
|
|
6019
|
+
const value = TrainingExperimentLearningRequestSchema.parse(input);
|
|
6020
|
+
const { baseModel, recipe, batch, evaluation, validationSplit, learningIntent } = value.form;
|
|
6021
|
+
return canonicalSha256({
|
|
6022
|
+
teamId: value.teamId,
|
|
6023
|
+
projectId: value.projectId,
|
|
6024
|
+
draftId: value.draftId,
|
|
6025
|
+
baseModel,
|
|
6026
|
+
recipe,
|
|
6027
|
+
batch,
|
|
6028
|
+
evaluation,
|
|
6029
|
+
validationSplit,
|
|
6030
|
+
learningIntent
|
|
6031
|
+
});
|
|
6032
|
+
}
|
|
6033
|
+
async function trainingExperimentTrainingInputHash(form) {
|
|
6034
|
+
const { baseModel, recipe, batch, evaluation, validationSplit } = form;
|
|
6035
|
+
return canonicalSha256({ baseModel, recipe, batch, evaluation, validationSplit });
|
|
6036
|
+
}
|
|
6037
|
+
async function trainingExperimentSavedConfiguration(form) {
|
|
6038
|
+
const saved = form.learningConfiguration;
|
|
6039
|
+
if (saved && saved.trainingInputHash !== await trainingExperimentTrainingInputHash(form))
|
|
6040
|
+
throw new Error("Save the changed training inputs before preparing this Model, or restore its accepted settings.");
|
|
6041
|
+
return saved;
|
|
6042
|
+
}
|
|
6043
|
+
function trainingExperimentInitialLearning(input) {
|
|
6044
|
+
const value = input.form.learningIntent;
|
|
6045
|
+
if (!value || !value.enabled && !input.expectedPolicy) throw new Error("Enable continual learning before saving its first policy.");
|
|
6046
|
+
return ModelInitialLearningSchema.parse({
|
|
6047
|
+
mode: value.mode,
|
|
6048
|
+
minimumTasks: Number(value.minimumTasks),
|
|
6049
|
+
localTime: value.localTime,
|
|
6050
|
+
timeZone: value.timeZone,
|
|
6051
|
+
maximumSpendUsd: Number(value.maximumSpendUsd),
|
|
6052
|
+
maximumDailySpendUsd: Number(value.maximumDailySpendUsd)
|
|
6053
|
+
});
|
|
6054
|
+
}
|
|
6055
|
+
function trainingExperimentLearningSettings(form) {
|
|
6056
|
+
return ModelProjectTrainingSetupSchema.parse({
|
|
6057
|
+
method: form.recipe.method,
|
|
6058
|
+
baseModel: form.baseModel,
|
|
6059
|
+
recipe: { ...form.recipe, dataset: { ...form.recipe.dataset && typeof form.recipe.dataset === "object" ? form.recipe.dataset : {}, validationSplit: form.validationSplit } },
|
|
6060
|
+
evaluationTasksetRef: form.evaluation,
|
|
6061
|
+
managedRolloutPlacement: "remote",
|
|
6062
|
+
...form.recipe.method === "grpo" && form.learningIntent?.continuationAdapterMode ? { continuationAdapterMode: form.learningIntent.continuationAdapterMode } : {}
|
|
6063
|
+
});
|
|
6064
|
+
}
|
|
6065
|
+
function createTrainingExperimentLearningClient(request) {
|
|
6066
|
+
return {
|
|
6067
|
+
async saveExperimentLearning(input) {
|
|
6068
|
+
const parsed = TrainingExperimentLearningRequestSchema.parse(input);
|
|
6069
|
+
const result = TrainingExperimentLearningReceiptSchema.parse(await request("/v1/training/preparations/from-draft/learning", { method: "POST", body: JSON.stringify(parsed) }));
|
|
6070
|
+
const pausing = parsed.form.learningIntent?.enabled === false && Boolean(parsed.expectedConfiguration && parsed.expectedPolicy);
|
|
6071
|
+
const expected = parsed.expectedConfiguration;
|
|
6072
|
+
const configurationMatches = pausing ? result.configuration.id === expected.id && result.configuration.revision === expected.expectedRevision && result.configuration.etag === expected.expectedEtag : result.configuration.name === parsed.form.name.trim();
|
|
6073
|
+
if (result.inputHash !== await trainingExperimentLearningInputHash(parsed) || result.configuration.teamId !== parsed.teamId || !configurationMatches || parsed.expectedPolicy && (result.policy.id !== parsed.expectedPolicy.id || result.policy.revision !== parsed.expectedPolicy.revision + 1))
|
|
6074
|
+
throw new OpenPondProtocolError("training_experiment_learning_mismatch", "The saved learning policy does not match its authored inputs.");
|
|
6075
|
+
return result;
|
|
6076
|
+
}
|
|
6077
|
+
};
|
|
6078
|
+
}
|
|
6079
|
+
|
|
6080
|
+
// src/training-estimates.ts
|
|
6081
|
+
import { z as z53 } from "zod";
|
|
5962
6082
|
|
|
5963
6083
|
// src/training-estimate-workload.ts
|
|
5964
|
-
import { z as
|
|
6084
|
+
import { z as z52 } from "zod";
|
|
5965
6085
|
var Hash38 = ModelProjectImmutableRefSchema.shape.contentHash;
|
|
5966
|
-
var Count =
|
|
5967
|
-
var Reason =
|
|
5968
|
-
var Coverage =
|
|
5969
|
-
var Identity =
|
|
6086
|
+
var Count = z52.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6087
|
+
var Reason = z52.string().trim().min(1).max(1e3);
|
|
6088
|
+
var Coverage = z52.enum(["complete", "bounded", "unavailable"]);
|
|
6089
|
+
var Identity = z52.object({
|
|
5970
6090
|
baseModel: ModelProjectBaseModelSchema.extend({
|
|
5971
|
-
revision:
|
|
5972
|
-
tokenizerRevision:
|
|
6091
|
+
revision: z52.string().trim().min(1).max(256),
|
|
6092
|
+
tokenizerRevision: z52.string().trim().min(1).max(256),
|
|
5973
6093
|
chatTemplateHash: Hash38
|
|
5974
6094
|
}).strict(),
|
|
5975
6095
|
/** Hash the full verified recipe, including optimizer and sampling settings. */
|
|
@@ -5978,17 +6098,17 @@ var Identity = z50.object({
|
|
|
5978
6098
|
harnessRelease: ModelProjectImmutableRefSchema,
|
|
5979
6099
|
dataset: ModelProjectImmutableRefSchema,
|
|
5980
6100
|
evaluationDataset: ModelProjectImmutableRefSchema.nullable(),
|
|
5981
|
-
evidenceSets:
|
|
6101
|
+
evidenceSets: z52.array(ModelProjectImmutableRefSchema).max(1e4)
|
|
5982
6102
|
}).strict();
|
|
5983
|
-
var Preprocessing =
|
|
5984
|
-
version:
|
|
6103
|
+
var Preprocessing = z52.object({
|
|
6104
|
+
version: z52.string().trim().min(1).max(191),
|
|
5985
6105
|
/** Includes policy framing, template invocation, admission and mask code. */
|
|
5986
6106
|
implementationHash: Hash38,
|
|
5987
6107
|
/** Hash of the verified tokenizer file inventory (paths, sizes and hashes). */
|
|
5988
6108
|
tokenizerAssetsHash: Hash38,
|
|
5989
|
-
enableThinking:
|
|
6109
|
+
enableThinking: z52.literal(false)
|
|
5990
6110
|
}).strict();
|
|
5991
|
-
var SftTokens =
|
|
6111
|
+
var SftTokens = z52.object({
|
|
5992
6112
|
promptTokens: Count,
|
|
5993
6113
|
retainedPromptTokens: Count,
|
|
5994
6114
|
/** Includes the final assistant terminal marker; prompt labels are masked. */
|
|
@@ -6000,7 +6120,7 @@ var SftTokens = z50.object({
|
|
|
6000
6120
|
context.addIssue({ code: "custom", message: "SFT tokens must preserve the target and partition the retained input" });
|
|
6001
6121
|
}
|
|
6002
6122
|
});
|
|
6003
|
-
var Population =
|
|
6123
|
+
var Population = z52.object({
|
|
6004
6124
|
coverage: Coverage,
|
|
6005
6125
|
total: Count.nullable(),
|
|
6006
6126
|
counted: Count,
|
|
@@ -6022,7 +6142,7 @@ function verifyPopulation(value, context) {
|
|
|
6022
6142
|
context.addIssue({ code: "custom", path: ["reason"], message: "Bounded coverage must explain its limit" });
|
|
6023
6143
|
}
|
|
6024
6144
|
}
|
|
6025
|
-
var PromptPopulation = Population.extend({ totals:
|
|
6145
|
+
var PromptPopulation = Population.extend({ totals: z52.object({ promptTokens: Count }).strict().nullable() }).superRefine(verifyPopulation).superRefine((value, context) => {
|
|
6026
6146
|
if (value.totals && value.totals.promptTokens < value.counted)
|
|
6027
6147
|
context.addIssue({ code: "custom", path: ["totals"], message: "Each counted initial request requires a nonempty prompt" });
|
|
6028
6148
|
});
|
|
@@ -6031,28 +6151,28 @@ var SftPopulation = Population.extend({ totals: SftTokens.nullable() }).superRef
|
|
|
6031
6151
|
context.addIssue({ code: "custom", path: ["totals"], message: "Each counted SFT row requires context and a complete target" });
|
|
6032
6152
|
});
|
|
6033
6153
|
var Common = {
|
|
6034
|
-
schemaVersion:
|
|
6154
|
+
schemaVersion: z52.literal("openpond.trainingEstimateWorkload.v1"),
|
|
6035
6155
|
identity: Identity.nullable(),
|
|
6036
6156
|
/** Required when immutable identity or native preprocessing cannot be verified. */
|
|
6037
6157
|
unavailableReason: Reason.nullable()
|
|
6038
6158
|
};
|
|
6039
|
-
var TrainingEstimateWorkloadSchema =
|
|
6040
|
-
|
|
6159
|
+
var TrainingEstimateWorkloadSchema = z52.discriminatedUnion("method", [
|
|
6160
|
+
z52.object({
|
|
6041
6161
|
...Common,
|
|
6042
|
-
method:
|
|
6162
|
+
method: z52.literal("sft"),
|
|
6043
6163
|
preprocessing: Preprocessing.extend({
|
|
6044
6164
|
maxSequenceLength: Count.min(2),
|
|
6045
|
-
promptTruncation:
|
|
6046
|
-
targetMask:
|
|
6165
|
+
promptTruncation: z52.literal("left_preserve_complete_target"),
|
|
6166
|
+
targetMask: z52.literal("completion_only")
|
|
6047
6167
|
}).strict().nullable(),
|
|
6048
6168
|
/** One exposure per distinct admitted row, before schedule repetition. */
|
|
6049
6169
|
trainingRows: SftPopulation,
|
|
6050
6170
|
evaluationRows: Count.nullable(),
|
|
6051
6171
|
/** Initial held-out requests only; held-out targets never enter SFT loss. */
|
|
6052
6172
|
evaluationInitialRequests: PromptPopulation,
|
|
6053
|
-
evaluationGeneratedCompletionTokens:
|
|
6173
|
+
evaluationGeneratedCompletionTokens: z52.null(),
|
|
6054
6174
|
evaluationGeneratedTokensReason: Reason,
|
|
6055
|
-
planned:
|
|
6175
|
+
planned: z52.object({
|
|
6056
6176
|
/** Native seeded epoch order, capped by maxSteps × batch × accumulation. */
|
|
6057
6177
|
exampleExposures: Count.nullable(),
|
|
6058
6178
|
optimizerSteps: Count.nullable(),
|
|
@@ -6062,13 +6182,13 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6062
6182
|
reason: Reason.nullable()
|
|
6063
6183
|
}).strict()
|
|
6064
6184
|
}).strict(),
|
|
6065
|
-
|
|
6185
|
+
z52.object({
|
|
6066
6186
|
...Common,
|
|
6067
|
-
method:
|
|
6187
|
+
method: z52.literal("grpo"),
|
|
6068
6188
|
preprocessing: Preprocessing.extend({
|
|
6069
6189
|
maxPromptTokens: Count.positive(),
|
|
6070
|
-
contextAdmission:
|
|
6071
|
-
addGenerationPrompt:
|
|
6190
|
+
contextAdmission: z52.literal("native_policy_context"),
|
|
6191
|
+
addGenerationPrompt: z52.literal(true)
|
|
6072
6192
|
}).strict().nullable(),
|
|
6073
6193
|
/** Distinct released rows, independent of repeated group/slot requests. */
|
|
6074
6194
|
trainingRows: Count.nullable(),
|
|
@@ -6077,8 +6197,8 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6077
6197
|
trainingInitialRequests: PromptPopulation,
|
|
6078
6198
|
evaluationInitialRequests: PromptPopulation,
|
|
6079
6199
|
/** Future generations and tool trajectories have no exact preflight count. */
|
|
6080
|
-
generatedCompletionTokens:
|
|
6081
|
-
subsequentToolTurnPromptTokens:
|
|
6200
|
+
generatedCompletionTokens: z52.null(),
|
|
6201
|
+
subsequentToolTurnPromptTokens: z52.null(),
|
|
6082
6202
|
generatedTokensReason: Reason
|
|
6083
6203
|
}).strict()
|
|
6084
6204
|
]).superRefine((workload, context) => {
|
|
@@ -6110,30 +6230,30 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6110
6230
|
});
|
|
6111
6231
|
|
|
6112
6232
|
// src/training-estimates.ts
|
|
6113
|
-
var Id35 =
|
|
6114
|
-
var Hash39 =
|
|
6115
|
-
var Timestamp3 =
|
|
6116
|
-
var NonNegative =
|
|
6117
|
-
var TrainingEstimateSourceSchema =
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
kind:
|
|
6233
|
+
var Id35 = z53.string().trim().min(1).max(191);
|
|
6234
|
+
var Hash39 = z53.string().regex(/^[a-f0-9]{64}$/);
|
|
6235
|
+
var Timestamp3 = z53.string().datetime({ offset: true });
|
|
6236
|
+
var NonNegative = z53.number().finite().nonnegative();
|
|
6237
|
+
var TrainingEstimateSourceSchema = z53.discriminatedUnion("kind", [
|
|
6238
|
+
z53.object({ kind: z53.literal("preparation"), id: Id35, planHash: Hash39, expectedRevision: z53.number().int().positive() }).strict(),
|
|
6239
|
+
z53.object({
|
|
6240
|
+
kind: z53.literal("configuration"),
|
|
6121
6241
|
id: Id35,
|
|
6122
|
-
expectedRevision:
|
|
6242
|
+
expectedRevision: z53.number().int().positive(),
|
|
6123
6243
|
expectedEtag: Hash39,
|
|
6124
6244
|
batch: ModelProjectVersionedRefSchema.nullable().default(null)
|
|
6125
6245
|
}).strict(),
|
|
6126
|
-
|
|
6246
|
+
z53.object({ kind: z53.literal("submission"), submission: z53.lazy(() => TrainingJobSubmissionSchema) }).strict()
|
|
6127
6247
|
]);
|
|
6128
|
-
var TrainingEstimateRequestSchema =
|
|
6129
|
-
schemaVersion:
|
|
6248
|
+
var TrainingEstimateRequestSchema = z53.object({
|
|
6249
|
+
schemaVersion: z53.literal("openpond.trainingEstimateRequest.v1"),
|
|
6130
6250
|
teamId: Id35,
|
|
6131
6251
|
source: TrainingEstimateSourceSchema,
|
|
6132
6252
|
gpuSelection: TrainingGpuSelectionSchema.optional()
|
|
6133
6253
|
}).strict();
|
|
6134
|
-
var PlanningRange =
|
|
6135
|
-
var TrainingEstimateComponentSchema =
|
|
6136
|
-
phase:
|
|
6254
|
+
var PlanningRange = z53.object({ low: NonNegative, high: NonNegative }).strict().refine((value) => value.high >= value.low, "Planning range must be ordered");
|
|
6255
|
+
var TrainingEstimateComponentSchema = z53.object({
|
|
6256
|
+
phase: z53.enum([
|
|
6137
6257
|
"gpu_allocation",
|
|
6138
6258
|
"startup",
|
|
6139
6259
|
"baseline_evaluation",
|
|
@@ -6146,12 +6266,12 @@ var TrainingEstimateComponentSchema = z51.object({
|
|
|
6146
6266
|
"cleanup",
|
|
6147
6267
|
"retention"
|
|
6148
6268
|
]),
|
|
6149
|
-
resource:
|
|
6269
|
+
resource: z53.enum(["gpu", "cpu", "judge", "storage", "network"]),
|
|
6150
6270
|
expectedUsd: NonNegative.nullable(),
|
|
6151
6271
|
expectedSeconds: NonNegative.nullable(),
|
|
6152
6272
|
planningRangeUsd: PlanningRange.nullable(),
|
|
6153
|
-
evidence:
|
|
6154
|
-
reason:
|
|
6273
|
+
evidence: z53.enum(["measured", "configured_rate", "unavailable"]),
|
|
6274
|
+
reason: z53.string().trim().min(1).max(1e3).nullable()
|
|
6155
6275
|
}).strict();
|
|
6156
6276
|
function trainingEstimateSourceIdentity(source) {
|
|
6157
6277
|
if (source.kind === "submission") return {
|
|
@@ -6168,67 +6288,67 @@ function trainingEstimateSourceIdentity(source) {
|
|
|
6168
6288
|
};
|
|
6169
6289
|
return { kind: source.kind, id: source.id, contentHash: source.expectedEtag, revision: source.expectedRevision };
|
|
6170
6290
|
}
|
|
6171
|
-
var TrainingEstimateSchema =
|
|
6172
|
-
schemaVersion:
|
|
6291
|
+
var TrainingEstimateSchema = z53.object({
|
|
6292
|
+
schemaVersion: z53.literal("openpond.trainingEstimate.v1"),
|
|
6173
6293
|
id: Id35,
|
|
6174
6294
|
teamId: Id35,
|
|
6175
6295
|
requestHash: Hash39,
|
|
6176
6296
|
inputHash: Hash39,
|
|
6177
|
-
source:
|
|
6178
|
-
kind:
|
|
6179
|
-
id:
|
|
6297
|
+
source: z53.object({
|
|
6298
|
+
kind: z53.enum(["preparation", "configuration", "submission"]),
|
|
6299
|
+
id: z53.string().trim().min(1).max(500),
|
|
6180
6300
|
contentHash: Hash39,
|
|
6181
|
-
revision:
|
|
6301
|
+
revision: z53.number().int().positive().nullable()
|
|
6182
6302
|
}).strict(),
|
|
6183
|
-
status:
|
|
6184
|
-
currency:
|
|
6303
|
+
status: z53.enum(["available", "partial", "insufficient_evidence"]),
|
|
6304
|
+
currency: z53.literal("USD"),
|
|
6185
6305
|
createdAt: Timestamp3,
|
|
6186
6306
|
expiresAt: Timestamp3,
|
|
6187
6307
|
estimatorVersion: Id35,
|
|
6188
6308
|
runtimeVersion: Id35,
|
|
6189
|
-
pricing:
|
|
6190
|
-
gpu:
|
|
6309
|
+
pricing: z53.object({ version: Id35, quoteExpiresAt: Timestamp3.nullable() }).strict(),
|
|
6310
|
+
gpu: z53.object({
|
|
6191
6311
|
requested: TrainingGpuSelectionSchema,
|
|
6192
|
-
resolved:
|
|
6312
|
+
resolved: z53.object({ availabilityId: Id35, gpuType: z53.string().min(1).max(256), gpuCount: z53.union([z53.literal(1), z53.literal(2)]) }).strict().nullable(),
|
|
6193
6313
|
customerHourlyUsd: NonNegative.nullable(),
|
|
6194
|
-
availability:
|
|
6314
|
+
availability: z53.enum(["available", "limited", "unavailable", "unknown"])
|
|
6195
6315
|
}).strict(),
|
|
6196
|
-
configuration:
|
|
6316
|
+
configuration: z53.object({
|
|
6197
6317
|
modelId: Id35,
|
|
6198
|
-
modelRevision:
|
|
6318
|
+
modelRevision: z53.string().min(1).max(256),
|
|
6199
6319
|
method: Id35,
|
|
6200
|
-
loraRank:
|
|
6201
|
-
adapterMode:
|
|
6202
|
-
groups:
|
|
6203
|
-
rolloutConcurrency:
|
|
6204
|
-
maxOutputTokens:
|
|
6205
|
-
trainingRows:
|
|
6206
|
-
evaluationRows:
|
|
6207
|
-
retentionDays:
|
|
6320
|
+
loraRank: z53.number().int().positive().nullable(),
|
|
6321
|
+
adapterMode: z53.enum(["residual_append", "shared", "sequential_merge"]).nullable(),
|
|
6322
|
+
groups: z53.number().int().nonnegative().nullable(),
|
|
6323
|
+
rolloutConcurrency: z53.number().int().positive().nullable(),
|
|
6324
|
+
maxOutputTokens: z53.number().int().positive().nullable(),
|
|
6325
|
+
trainingRows: z53.number().int().nonnegative().nullable(),
|
|
6326
|
+
evaluationRows: z53.number().int().nonnegative().nullable(),
|
|
6327
|
+
retentionDays: z53.number().int().positive().nullable(),
|
|
6208
6328
|
approvedMaximumUsd: NonNegative.nullable()
|
|
6209
6329
|
}).strict(),
|
|
6210
6330
|
/** Producers bind supplied evidence into inputHash. Absence has no default and
|
|
6211
6331
|
* preserves the identity of estimates produced before native token preflight. */
|
|
6212
6332
|
workload: TrainingEstimateWorkloadSchema.optional(),
|
|
6213
|
-
cost:
|
|
6333
|
+
cost: z53.object({
|
|
6214
6334
|
expectedUsd: NonNegative.nullable(),
|
|
6215
6335
|
planningRangeUsd: PlanningRange.nullable(),
|
|
6216
6336
|
knownMinimumUsd: NonNegative,
|
|
6217
6337
|
recommendedMaximumUsd: NonNegative.nullable(),
|
|
6218
6338
|
minimumCleanupReserveUsd: NonNegative.nullable(),
|
|
6219
|
-
components:
|
|
6339
|
+
components: z53.array(TrainingEstimateComponentSchema).max(50)
|
|
6220
6340
|
}).strict(),
|
|
6221
|
-
executionSeconds:
|
|
6222
|
-
queueWaitSeconds:
|
|
6223
|
-
calibration:
|
|
6341
|
+
executionSeconds: z53.object({ expected: NonNegative.nullable(), planningRange: PlanningRange.nullable() }).strict(),
|
|
6342
|
+
queueWaitSeconds: z53.object({ expected: NonNegative, planningRange: PlanningRange.nullable() }).strict().nullable(),
|
|
6343
|
+
calibration: z53.object({
|
|
6224
6344
|
version: Id35,
|
|
6225
6345
|
cohortHash: Hash39,
|
|
6226
|
-
completedSamples:
|
|
6227
|
-
partialSamples:
|
|
6228
|
-
scope:
|
|
6346
|
+
completedSamples: z53.number().int().nonnegative(),
|
|
6347
|
+
partialSamples: z53.number().int().nonnegative(),
|
|
6348
|
+
scope: z53.enum(["workspace", "authorized_aggregate"])
|
|
6229
6349
|
}).strict(),
|
|
6230
|
-
assumptions:
|
|
6231
|
-
unknowns:
|
|
6350
|
+
assumptions: z53.array(z53.string().trim().min(1).max(1e3)).max(50),
|
|
6351
|
+
unknowns: z53.array(z53.string().trim().min(1).max(1e3)).max(50),
|
|
6232
6352
|
review: TrainingEstimateReviewSchema
|
|
6233
6353
|
}).strict().superRefine((estimate, context) => {
|
|
6234
6354
|
const allocation = estimate.cost.components.filter((component) => component.phase === "gpu_allocation");
|
|
@@ -6315,7 +6435,7 @@ async function parseAndVerifyTrainingEstimate(raw, request) {
|
|
|
6315
6435
|
}
|
|
6316
6436
|
}
|
|
6317
6437
|
} else if (workload.method === "grpo" && workload.preprocessing) {
|
|
6318
|
-
const recipe =
|
|
6438
|
+
const recipe = z53.object({ dataset: z53.object({ maxPromptTokens: z53.number().int().positive() }) }).safeParse(submission.job.recipe);
|
|
6319
6439
|
mismatch2 ||= !recipe.success || workload.preprocessing.maxPromptTokens !== recipe.data.dataset.maxPromptTokens;
|
|
6320
6440
|
}
|
|
6321
6441
|
if (mismatch2) throw new OpenPondProtocolError("training_estimate_scope_mismatch", "Workload evidence does not match the exact submitted model, recipe and released data.");
|
|
@@ -6329,34 +6449,34 @@ async function parseAndVerifyTrainingEstimate(raw, request) {
|
|
|
6329
6449
|
}
|
|
6330
6450
|
|
|
6331
6451
|
// src/training-funding.ts
|
|
6332
|
-
import { z as
|
|
6333
|
-
var Id36 =
|
|
6334
|
-
var Hash40 =
|
|
6335
|
-
var Amount =
|
|
6336
|
-
var Decimal =
|
|
6337
|
-
var Timestamp4 =
|
|
6338
|
-
var TrainingFundingDraftRefSchema =
|
|
6452
|
+
import { z as z54 } from "zod";
|
|
6453
|
+
var Id36 = z54.string().trim().min(1).max(240);
|
|
6454
|
+
var Hash40 = z54.string().regex(/^[a-f0-9]{64}$/);
|
|
6455
|
+
var Amount = z54.number().positive().max(1e6);
|
|
6456
|
+
var Decimal = z54.string().regex(/^\d+(?:\.\d{1,6})?$/);
|
|
6457
|
+
var Timestamp4 = z54.iso.datetime();
|
|
6458
|
+
var TrainingFundingDraftRefSchema = z54.object({
|
|
6339
6459
|
id: Id36,
|
|
6340
|
-
revision:
|
|
6460
|
+
revision: z54.number().int().positive(),
|
|
6341
6461
|
contentHash: Hash40,
|
|
6342
6462
|
projectId: Id36.nullable()
|
|
6343
6463
|
}).strict();
|
|
6344
|
-
var TrainingFundingRequestSchema =
|
|
6345
|
-
schemaVersion:
|
|
6464
|
+
var TrainingFundingRequestSchema = z54.object({
|
|
6465
|
+
schemaVersion: z54.literal("openpond.trainingFundingRequest.v1"),
|
|
6346
6466
|
teamId: Id36,
|
|
6347
6467
|
maximumSpendUsd: Amount,
|
|
6348
6468
|
draft: TrainingFundingDraftRefSchema.nullable().default(null)
|
|
6349
6469
|
}).strict();
|
|
6350
|
-
var TrainingFundingSchema =
|
|
6351
|
-
schemaVersion:
|
|
6470
|
+
var TrainingFundingSchema = z54.object({
|
|
6471
|
+
schemaVersion: z54.literal("openpond.trainingFunding.v1"),
|
|
6352
6472
|
teamId: Id36,
|
|
6353
6473
|
actorId: Id36,
|
|
6354
6474
|
requestHash: Hash40,
|
|
6355
6475
|
maximumSpendUsd: Amount,
|
|
6356
6476
|
draft: TrainingFundingDraftRefSchema.nullable(),
|
|
6357
|
-
state:
|
|
6358
|
-
canViewBalance:
|
|
6359
|
-
canPurchase:
|
|
6477
|
+
state: z54.enum(["covered", "insufficient_credit", "member_limit", "unavailable"]),
|
|
6478
|
+
canViewBalance: z54.boolean(),
|
|
6479
|
+
canPurchase: z54.boolean(),
|
|
6360
6480
|
availableUsageUsd: Decimal.nullable(),
|
|
6361
6481
|
prepaidCreditUsd: Decimal.nullable(),
|
|
6362
6482
|
checkedAt: Timestamp4,
|
|
@@ -6367,21 +6487,21 @@ var TrainingFundingSchema = z52.object({
|
|
|
6367
6487
|
if (Date.parse(value.expiresAt) <= Date.parse(value.checkedAt))
|
|
6368
6488
|
context.addIssue({ code: "custom", path: ["expiresAt"], message: "Funding observations must expire after their check." });
|
|
6369
6489
|
});
|
|
6370
|
-
var TrainingFundingHandoffRequestSchema =
|
|
6371
|
-
schemaVersion:
|
|
6490
|
+
var TrainingFundingHandoffRequestSchema = z54.object({
|
|
6491
|
+
schemaVersion: z54.literal("openpond.trainingFundingHandoffRequest.v1"),
|
|
6372
6492
|
teamId: Id36,
|
|
6373
6493
|
maximumSpendUsd: Amount.nullable(),
|
|
6374
6494
|
draft: TrainingFundingDraftRefSchema
|
|
6375
6495
|
}).strict();
|
|
6376
|
-
var TrainingFundingHandoffSchema =
|
|
6377
|
-
schemaVersion:
|
|
6496
|
+
var TrainingFundingHandoffSchema = z54.object({
|
|
6497
|
+
schemaVersion: z54.literal("openpond.trainingFundingHandoff.v1"),
|
|
6378
6498
|
teamId: Id36,
|
|
6379
6499
|
actorId: Id36,
|
|
6380
6500
|
requestHash: Hash40,
|
|
6381
6501
|
maximumSpendUsd: Amount.nullable(),
|
|
6382
6502
|
draft: TrainingFundingDraftRefSchema,
|
|
6383
|
-
canPurchase:
|
|
6384
|
-
billingUrl:
|
|
6503
|
+
canPurchase: z54.boolean(),
|
|
6504
|
+
billingUrl: z54.string().url().nullable(),
|
|
6385
6505
|
checkedAt: Timestamp4,
|
|
6386
6506
|
expiresAt: Timestamp4
|
|
6387
6507
|
}).strict().superRefine((value, context) => {
|
|
@@ -6424,8 +6544,8 @@ function createTrainingFundingClient(request) {
|
|
|
6424
6544
|
async function parseAndVerifyDatasetTrainingReviewReceipt(raw, input, actorId) {
|
|
6425
6545
|
const request = DatasetTrainingReviewRequestSchema.parse(input);
|
|
6426
6546
|
const value = DatasetTrainingReviewReceiptSchema.parse(raw);
|
|
6427
|
-
const { contentHash, ...content } = value;
|
|
6428
|
-
if (
|
|
6547
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
6548
|
+
if (contentHash2 !== contentHash(content) || value.requestHash !== contentHash(request) || value.id !== `dataset-review-${contentHash([value.teamId, value.actorId, value.operationId])}` || value.teamId !== request.teamId || actorId && value.actorId !== actorId || value.operationId !== request.operationId || value.packageHash !== request.packageHash || canonicalJson(value.dataset) !== canonicalJson(request.dataset) || value.purpose !== request.purpose)
|
|
6429
6549
|
throw new OpenPondProtocolError("dataset_training_review_mismatch", "The Dataset review receipt differs from its exact source or operation.");
|
|
6430
6550
|
if (new Set(value.evidence.map((ref) => ref.id)).size !== value.evidence.length || new Set(value.proposals.map((ref) => ref.id)).size !== value.proposals.length || value.proposals.length > value.evidence.length || request.taskIds && value.evidence.length !== request.taskIds.length)
|
|
6431
6551
|
throw new OpenPondProtocolError("dataset_training_review_inventory_mismatch", "The Dataset review returned another example inventory.");
|
|
@@ -6444,37 +6564,37 @@ function createDatasetTrainingReviewClient(request) {
|
|
|
6444
6564
|
}
|
|
6445
6565
|
|
|
6446
6566
|
// src/training-model-save.ts
|
|
6447
|
-
import { z as
|
|
6448
|
-
var Id37 =
|
|
6449
|
-
var Hash41 =
|
|
6450
|
-
var TrainingResultSaveRequestSchema =
|
|
6451
|
-
schemaVersion:
|
|
6567
|
+
import { z as z55 } from "zod";
|
|
6568
|
+
var Id37 = z55.string().trim().min(1).max(200);
|
|
6569
|
+
var Hash41 = z55.string().regex(/^[a-f0-9]{64}$/);
|
|
6570
|
+
var TrainingResultSaveRequestSchema = z55.object({
|
|
6571
|
+
schemaVersion: z55.literal("openpond.trainingResultSave.v1"),
|
|
6452
6572
|
teamId: Id37,
|
|
6453
6573
|
operationId: Id37,
|
|
6454
|
-
name:
|
|
6455
|
-
expectedModelRevision:
|
|
6574
|
+
name: z55.string().trim().min(1).max(200),
|
|
6575
|
+
expectedModelRevision: z55.number().int().positive(),
|
|
6456
6576
|
submissionHash: Hash41,
|
|
6457
6577
|
artifact: ModelProjectImmutableRefSchema,
|
|
6458
6578
|
checkpointId: Id37
|
|
6459
6579
|
}).strict();
|
|
6460
6580
|
var TrainingResultSaveIntentSchema = TrainingResultSaveRequestSchema.omit({ operationId: true }).extend({ jobId: Id37 }).strict();
|
|
6461
|
-
var TrainingResultSaveCommandSchema =
|
|
6462
|
-
var TrainingResultSaveReceiptSchema =
|
|
6463
|
-
schemaVersion:
|
|
6581
|
+
var TrainingResultSaveCommandSchema = z55.object({ jobId: Id37, request: TrainingResultSaveRequestSchema }).strict();
|
|
6582
|
+
var TrainingResultSaveReceiptSchema = z55.object({
|
|
6583
|
+
schemaVersion: z55.literal("openpond.trainingResultSaveReceipt.v1"),
|
|
6464
6584
|
teamId: Id37,
|
|
6465
6585
|
actorId: Id37,
|
|
6466
6586
|
operationId: Id37,
|
|
6467
6587
|
requestHash: Hash41,
|
|
6468
|
-
model:
|
|
6469
|
-
version:
|
|
6588
|
+
model: z55.lazy(() => HostedModelProjectSummarySchema),
|
|
6589
|
+
version: z55.lazy(() => TrainingModelVersionSchema),
|
|
6470
6590
|
contentHash: Hash41
|
|
6471
6591
|
}).strict();
|
|
6472
|
-
var TrainingSavedModelQuerySchema =
|
|
6473
|
-
var TrainingSavedModelSchema =
|
|
6474
|
-
schemaVersion:
|
|
6592
|
+
var TrainingSavedModelQuerySchema = z55.object({ teamId: Id37 }).strict();
|
|
6593
|
+
var TrainingSavedModelSchema = z55.object({
|
|
6594
|
+
schemaVersion: z55.literal("openpond.trainingSavedModel.v1"),
|
|
6475
6595
|
teamId: Id37,
|
|
6476
|
-
model:
|
|
6477
|
-
version:
|
|
6596
|
+
model: z55.lazy(() => HostedModelProjectSummarySchema),
|
|
6597
|
+
version: z55.lazy(() => TrainingModelVersionSchema).nullable()
|
|
6478
6598
|
}).strict();
|
|
6479
6599
|
async function parseAndVerifyTrainingSavedModel(raw, expected) {
|
|
6480
6600
|
const value = TrainingSavedModelSchema.parse(raw);
|
|
@@ -6490,9 +6610,9 @@ async function parseAndVerifyTrainingSavedModel(raw, expected) {
|
|
|
6490
6610
|
async function parseAndVerifyTrainingResultSave(raw, expected) {
|
|
6491
6611
|
const value = TrainingResultSaveReceiptSchema.parse(raw);
|
|
6492
6612
|
const request = TrainingResultSaveRequestSchema.parse(expected.request);
|
|
6493
|
-
const { contentHash, ...content } = value;
|
|
6613
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
6494
6614
|
const version = await parseAndVerifyTrainingModelVersion(value.version, { teamId: request.teamId, modelProjectId: value.model.id, jobId: expected.jobId });
|
|
6495
|
-
if (
|
|
6615
|
+
if (contentHash2 !== await canonicalSha256(content) || value.requestHash !== await canonicalSha256(request) || value.teamId !== request.teamId || value.model.teamId !== request.teamId || expected.actorId && value.actorId !== expected.actorId || value.operationId !== request.operationId || value.model.name !== request.name || value.model.revision !== request.expectedModelRevision + 1 || value.model.portableProjectId !== version.portableProjectId || version.request.submissionHash !== request.submissionHash || version.candidate.artifact.id !== request.artifact.id || version.candidate.artifact.contentHash !== request.artifact.contentHash || version.candidate.checkpointId !== request.checkpointId)
|
|
6496
6616
|
throw new OpenPondProtocolError("training_result_save_mismatch", "The saved Model differs from the reviewed training result or name.");
|
|
6497
6617
|
return value;
|
|
6498
6618
|
}
|
|
@@ -6513,47 +6633,47 @@ function createTrainingModelSaveClient(request) {
|
|
|
6513
6633
|
}
|
|
6514
6634
|
|
|
6515
6635
|
// src/training-model-serving.ts
|
|
6516
|
-
import { z as
|
|
6636
|
+
import { z as z57 } from "zod";
|
|
6517
6637
|
|
|
6518
6638
|
// src/training-model-serving-control.ts
|
|
6519
|
-
import { z as
|
|
6520
|
-
var Id38 =
|
|
6521
|
-
var Hash42 =
|
|
6522
|
-
var TrainingModelServingControlSchema =
|
|
6639
|
+
import { z as z56 } from "zod";
|
|
6640
|
+
var Id38 = z56.string().trim().min(1).max(500);
|
|
6641
|
+
var Hash42 = z56.string().regex(/^[a-f0-9]{64}$/);
|
|
6642
|
+
var TrainingModelServingControlSchema = z56.object({
|
|
6523
6643
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
6524
|
-
schemaVersion:
|
|
6644
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControl.v1"),
|
|
6525
6645
|
teamId: Id38,
|
|
6526
6646
|
modelProjectId: Id38,
|
|
6527
6647
|
versionHash: Hash42,
|
|
6528
6648
|
artifact: ModelProjectImmutableRefSchema,
|
|
6529
6649
|
actorId: Id38,
|
|
6530
6650
|
operationId: Id38,
|
|
6531
|
-
revision:
|
|
6532
|
-
desiredState:
|
|
6533
|
-
phase:
|
|
6534
|
-
capacityState:
|
|
6651
|
+
revision: z56.number().int().positive(),
|
|
6652
|
+
desiredState: z56.enum(["active", "stopped"]),
|
|
6653
|
+
phase: z56.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
6654
|
+
capacityState: z56.enum(["pending", "shared", "retiring", "released"]),
|
|
6535
6655
|
modelId: Id38,
|
|
6536
6656
|
deploymentId: Id38,
|
|
6537
6657
|
poolId: Id38,
|
|
6538
|
-
idleTimeoutSeconds:
|
|
6658
|
+
idleTimeoutSeconds: z56.number().int().min(60).max(3600),
|
|
6539
6659
|
failureCode: Id38.nullable(),
|
|
6540
|
-
updatedAt:
|
|
6660
|
+
updatedAt: z56.string().datetime({ offset: true })
|
|
6541
6661
|
}).strict();
|
|
6542
|
-
var TrainingModelServingControlRequestSchema =
|
|
6662
|
+
var TrainingModelServingControlRequestSchema = z56.object({
|
|
6543
6663
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
6544
|
-
schemaVersion:
|
|
6664
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControlRequest.v1"),
|
|
6545
6665
|
teamId: Id38,
|
|
6546
6666
|
operationId: Id38,
|
|
6547
6667
|
artifact: ModelProjectImmutableRefSchema,
|
|
6548
6668
|
versionHash: Hash42,
|
|
6549
|
-
expectedRevision:
|
|
6550
|
-
action:
|
|
6551
|
-
idleTimeoutSeconds:
|
|
6669
|
+
expectedRevision: z56.number().int().nonnegative(),
|
|
6670
|
+
action: z56.enum(["activate", "stop"]),
|
|
6671
|
+
idleTimeoutSeconds: z56.number().int().min(60).max(3600)
|
|
6552
6672
|
}).strict();
|
|
6553
6673
|
var TrainingModelServingControlIntentSchema = TrainingModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id38 }).strict();
|
|
6554
|
-
var TrainingModelServingControlCommandSchema =
|
|
6555
|
-
var TrainingModelServingControlReceiptSchema =
|
|
6556
|
-
schemaVersion:
|
|
6674
|
+
var TrainingModelServingControlCommandSchema = z56.object({ modelProjectId: Id38, request: TrainingModelServingControlRequestSchema }).strict();
|
|
6675
|
+
var TrainingModelServingControlReceiptSchema = z56.object({
|
|
6676
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControlReceipt.v1"),
|
|
6557
6677
|
teamId: Id38,
|
|
6558
6678
|
modelProjectId: Id38,
|
|
6559
6679
|
actorId: Id38,
|
|
@@ -6563,8 +6683,8 @@ var TrainingModelServingControlReceiptSchema = z54.object({
|
|
|
6563
6683
|
}).strict();
|
|
6564
6684
|
async function parseAndVerifyTrainingModelServingControl(raw, expected) {
|
|
6565
6685
|
const value = TrainingModelServingControlReceiptSchema.parse(raw), request = TrainingModelServingControlRequestSchema.parse(expected.request);
|
|
6566
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
6567
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
6686
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
6687
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || await canonicalSha256(value.request) !== await canonicalSha256(request) || value.modelProjectId !== expected.modelProjectId || value.teamId !== request.teamId || expected.actorId && value.actorId !== expected.actorId || control2.actorId !== value.actorId || control2.teamId !== request.teamId || control2.modelProjectId !== value.modelProjectId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.artifact.id !== request.artifact.id || control2.artifact.contentHash !== request.artifact.contentHash || control2.modelId !== `personalized:model:${expected.modelProjectId}` || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
6568
6688
|
throw new OpenPondProtocolError("training_model_serving_control_mismatch", "The serving command differs from its reviewed Model, version or action.");
|
|
6569
6689
|
return value;
|
|
6570
6690
|
}
|
|
@@ -6579,56 +6699,56 @@ function createTrainingModelServingControlClient(request) {
|
|
|
6579
6699
|
}
|
|
6580
6700
|
|
|
6581
6701
|
// src/training-model-serving.ts
|
|
6582
|
-
var Id39 =
|
|
6583
|
-
var Hash43 =
|
|
6584
|
-
var Timestamp5 =
|
|
6585
|
-
var TrainingModelServingQuerySchema =
|
|
6586
|
-
var TrainingServingVersionSchema =
|
|
6587
|
-
var TrainingServingRegistrySchema =
|
|
6702
|
+
var Id39 = z57.string().trim().min(1).max(500);
|
|
6703
|
+
var Hash43 = z57.string().regex(/^[a-f0-9]{64}$/);
|
|
6704
|
+
var Timestamp5 = z57.string().datetime({ offset: true });
|
|
6705
|
+
var TrainingModelServingQuerySchema = z57.object({ teamId: Id39, versionHash: Hash43 }).strict();
|
|
6706
|
+
var TrainingServingVersionSchema = z57.lazy(() => TrainingModelVersionSchema);
|
|
6707
|
+
var TrainingServingRegistrySchema = z57.object({
|
|
6588
6708
|
artifact: ModelProjectImmutableRefSchema,
|
|
6589
6709
|
baseProfileId: Id39,
|
|
6590
6710
|
state: Id39,
|
|
6591
|
-
qualified:
|
|
6592
|
-
revoked:
|
|
6593
|
-
deleted:
|
|
6594
|
-
reason:
|
|
6595
|
-
source:
|
|
6711
|
+
qualified: z57.boolean(),
|
|
6712
|
+
revoked: z57.boolean(),
|
|
6713
|
+
deleted: z57.boolean(),
|
|
6714
|
+
reason: z57.enum(["qualified", "evaluation_pending", "post_training_pending", "evaluation_failed", "candidate_rejected", "artifact_revoked", "artifact_deleted", "runtime_unavailable"]),
|
|
6715
|
+
source: z57.object({ jobId: Id39, artifact: ModelProjectImmutableRefSchema, checkpointId: Id39 }).strict()
|
|
6596
6716
|
}).strict();
|
|
6597
|
-
var TrainingServingDeploymentSchema =
|
|
6717
|
+
var TrainingServingDeploymentSchema = z57.object({
|
|
6598
6718
|
id: Id39,
|
|
6599
6719
|
artifactId: Id39,
|
|
6600
6720
|
poolId: Id39.nullable(),
|
|
6601
|
-
revision:
|
|
6602
|
-
state:
|
|
6603
|
-
revoked:
|
|
6721
|
+
revision: z57.number().int().positive(),
|
|
6722
|
+
state: z57.enum(["requested", "deploying", "ready", "degraded", "deleting", "deleted", "failed"]),
|
|
6723
|
+
revoked: z57.boolean(),
|
|
6604
6724
|
lastReadyCheckAt: Timestamp5.nullable(),
|
|
6605
6725
|
updatedAt: Timestamp5
|
|
6606
6726
|
}).strict();
|
|
6607
|
-
var TrainingServingBindingSchema =
|
|
6608
|
-
var TrainingServingLoadEvidenceSchema =
|
|
6727
|
+
var TrainingServingBindingSchema = z57.object({ id: Id39, modelId: Id39, artifactId: Id39, deploymentId: Id39, revision: z57.number().int().positive() }).strict();
|
|
6728
|
+
var TrainingServingLoadEvidenceSchema = z57.object({
|
|
6609
6729
|
requestId: Id39,
|
|
6610
6730
|
receipt: ModelProjectImmutableRefSchema,
|
|
6611
6731
|
artifact: ModelProjectImmutableRefSchema,
|
|
6612
6732
|
deploymentId: Id39,
|
|
6613
6733
|
poolId: Id39,
|
|
6614
|
-
workerImageDigest:
|
|
6734
|
+
workerImageDigest: z57.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
6615
6735
|
completedAt: Timestamp5
|
|
6616
6736
|
}).strict();
|
|
6617
|
-
var TrainingModelServingContentSchema =
|
|
6737
|
+
var TrainingModelServingContentSchema = z57.object({
|
|
6618
6738
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
6619
|
-
schemaVersion:
|
|
6739
|
+
schemaVersion: z57.literal("openpond.trainingModelServing.v1"),
|
|
6620
6740
|
teamId: Id39,
|
|
6621
6741
|
modelProjectId: Id39,
|
|
6622
6742
|
observedAt: Timestamp5,
|
|
6623
6743
|
version: TrainingServingVersionSchema,
|
|
6624
6744
|
registry: TrainingServingRegistrySchema.nullable(),
|
|
6625
6745
|
control: TrainingModelServingControlSchema.nullable(),
|
|
6626
|
-
cleanup:
|
|
6627
|
-
deployments:
|
|
6628
|
-
pools:
|
|
6629
|
-
bindings:
|
|
6746
|
+
cleanup: z57.array(TrainingModelServingControlSchema).max(100),
|
|
6747
|
+
deployments: z57.array(TrainingServingDeploymentSchema).max(100),
|
|
6748
|
+
pools: z57.array(TrainingServingPoolSchema).max(100),
|
|
6749
|
+
bindings: z57.array(TrainingServingBindingSchema).max(100),
|
|
6630
6750
|
lastVerifiedInference: TrainingServingLoadEvidenceSchema.nullable(),
|
|
6631
|
-
state:
|
|
6751
|
+
state: z57.enum(["unpublished", "qualification_pending", "unavailable", "inactive", "starting", "active", "retiring"])
|
|
6632
6752
|
}).strict();
|
|
6633
6753
|
var TrainingModelServingSchema = TrainingModelServingContentSchema.extend({ contentHash: Hash43 }).strict();
|
|
6634
6754
|
function trainingModelServingState(value) {
|
|
@@ -6644,13 +6764,13 @@ function trainingModelServingState(value) {
|
|
|
6644
6764
|
return value.bindings.length ? "unavailable" : "inactive";
|
|
6645
6765
|
}
|
|
6646
6766
|
async function parseAndVerifyTrainingModelServing(raw, expected) {
|
|
6647
|
-
const value = TrainingModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
6767
|
+
const value = TrainingModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6648
6768
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "training" }, value.control);
|
|
6649
6769
|
await parseAndVerifyTrainingModelVersion(value.version, expected);
|
|
6650
6770
|
function fail8() {
|
|
6651
6771
|
throw new OpenPondProtocolError("training_model_serving_mismatch", "Serving evidence differs from the exact saved Model, registry or deployment.");
|
|
6652
6772
|
}
|
|
6653
|
-
if (value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash ||
|
|
6773
|
+
if (value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || contentHash2 !== await canonicalSha256(content) || value.state !== trainingModelServingState(value)) fail8();
|
|
6654
6774
|
for (const rows of [value.deployments, value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
6655
6775
|
const registry = value.registry;
|
|
6656
6776
|
const control2 = value.control;
|
|
@@ -6676,13 +6796,13 @@ function createTrainingModelServingClient(request) {
|
|
|
6676
6796
|
}
|
|
6677
6797
|
|
|
6678
6798
|
// src/steering-model-serving.ts
|
|
6679
|
-
import { z as
|
|
6799
|
+
import { z as z59 } from "zod";
|
|
6680
6800
|
|
|
6681
6801
|
// src/steering-inference.ts
|
|
6682
|
-
import { z as
|
|
6683
|
-
var Hash44 =
|
|
6684
|
-
var Id40 =
|
|
6685
|
-
var SteeringInferenceOptionsSchema =
|
|
6802
|
+
import { z as z58 } from "zod";
|
|
6803
|
+
var Hash44 = z58.string().regex(/^[a-f0-9]{64}$/);
|
|
6804
|
+
var Id40 = z58.string().trim().min(1).max(500);
|
|
6805
|
+
var SteeringInferenceOptionsSchema = z58.object({
|
|
6686
6806
|
savedModel: SavedSteeringModelSelectionSchema.optional(),
|
|
6687
6807
|
steering: SteeringPublicationReferenceSchema.nullable().optional()
|
|
6688
6808
|
}).strict();
|
|
@@ -6691,9 +6811,9 @@ async function savedSteeringModelSelection(raw) {
|
|
|
6691
6811
|
await parseAndVerifySavedModelVersion(version);
|
|
6692
6812
|
return { modelProjectId: version.modelProjectId, versionHash: version.contentHash };
|
|
6693
6813
|
}
|
|
6694
|
-
var ResolvedSteeringSelectionSchema =
|
|
6695
|
-
schemaVersion:
|
|
6696
|
-
requested:
|
|
6814
|
+
var ResolvedSteeringSelectionSchema = z58.object({
|
|
6815
|
+
schemaVersion: z58.literal("openpond.resolvedSteeringSelection.v1"),
|
|
6816
|
+
requested: z58.enum(["inherit", "off", "override"]),
|
|
6697
6817
|
savedModel: SavedSteeringModelSelectionSchema.nullable(),
|
|
6698
6818
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6699
6819
|
effectivePublication: SteeringPublicationReferenceSchema.nullable(),
|
|
@@ -6709,84 +6829,84 @@ async function parseAndVerifyResolvedSteeringSelection(raw, options) {
|
|
|
6709
6829
|
throw new OpenPondProtocolError("steering_selection_mismatch", "The admitted steering selection differs from the exact request and default.");
|
|
6710
6830
|
return value;
|
|
6711
6831
|
}
|
|
6712
|
-
var SteeringInferenceReceiptContentSchema =
|
|
6713
|
-
schemaVersion:
|
|
6832
|
+
var SteeringInferenceReceiptContentSchema = z58.object({
|
|
6833
|
+
schemaVersion: z58.literal("openpond.steeringInferenceReceipt.v1"),
|
|
6714
6834
|
teamId: Id40,
|
|
6715
6835
|
requestId: Id40,
|
|
6716
6836
|
requestHash: Hash44,
|
|
6717
6837
|
selection: ResolvedSteeringSelectionSchema,
|
|
6718
6838
|
poolId: Id40,
|
|
6719
|
-
routingBinding:
|
|
6839
|
+
routingBinding: z58.object({ id: Id40, revision: z58.number().int().positive() }).strict().nullable(),
|
|
6720
6840
|
runtimeHash: Hash44,
|
|
6721
|
-
workerImageDigest:
|
|
6722
|
-
engineGeneration:
|
|
6841
|
+
workerImageDigest: z58.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
6842
|
+
engineGeneration: z58.number().int().positive(),
|
|
6723
6843
|
cacheNamespace: Hash44,
|
|
6724
|
-
completedAt:
|
|
6844
|
+
completedAt: z58.iso.datetime()
|
|
6725
6845
|
}).strict();
|
|
6726
6846
|
var SteeringInferenceReceiptSchema = SteeringInferenceReceiptContentSchema.extend({ contentHash: Hash44 }).strict();
|
|
6727
6847
|
async function parseAndVerifySteeringInferenceReceipt(raw, expected) {
|
|
6728
|
-
const value = SteeringInferenceReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
6848
|
+
const value = SteeringInferenceReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6729
6849
|
await parseAndVerifyResolvedSteeringSelection(value.selection, expected.options);
|
|
6730
|
-
if (
|
|
6850
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.requestId !== expected.requestId || value.requestHash !== expected.requestHash || canonicalJson(value.selection) !== canonicalJson(expected.selection) || value.poolId !== expected.poolId || canonicalJson(value.routingBinding) !== canonicalJson(expected.routingBinding) || value.runtimeHash !== expected.runtimeHash || value.workerImageDigest !== expected.workerImageDigest || value.engineGeneration !== expected.engineGeneration || value.cacheNamespace !== expected.cacheNamespace)
|
|
6731
6851
|
throw new OpenPondProtocolError("steering_inference_receipt_mismatch", "The completed inference differs from its admitted steering, runtime or cache identity.");
|
|
6732
6852
|
return value;
|
|
6733
6853
|
}
|
|
6734
6854
|
|
|
6735
6855
|
// src/steering-model-serving.ts
|
|
6736
|
-
var Id41 =
|
|
6737
|
-
var Hash45 =
|
|
6738
|
-
var BindingRef5 =
|
|
6739
|
-
var Timestamp6 =
|
|
6740
|
-
var SteeringModelServingControlRequestSchema =
|
|
6856
|
+
var Id41 = z59.string().trim().min(1).max(240);
|
|
6857
|
+
var Hash45 = z59.string().regex(/^[a-f0-9]{64}$/);
|
|
6858
|
+
var BindingRef5 = z59.object({ id: Id41, revision: z59.number().int().positive() }).strict();
|
|
6859
|
+
var Timestamp6 = z59.iso.datetime();
|
|
6860
|
+
var SteeringModelServingControlRequestSchema = z59.object({
|
|
6741
6861
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
6742
|
-
schemaVersion:
|
|
6862
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControlRequest.v1"),
|
|
6743
6863
|
teamId: Id41,
|
|
6744
6864
|
operationId: Id41,
|
|
6745
6865
|
versionHash: Hash45,
|
|
6746
|
-
expectedRevision:
|
|
6747
|
-
action:
|
|
6866
|
+
expectedRevision: z59.number().int().nonnegative(),
|
|
6867
|
+
action: z59.enum(["activate", "stop"]),
|
|
6748
6868
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6749
|
-
idleTimeoutSeconds:
|
|
6869
|
+
idleTimeoutSeconds: z59.number().int().min(60).max(3600)
|
|
6750
6870
|
}).strict();
|
|
6751
6871
|
var SteeringModelServingControlIntentSchema = SteeringModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id41 }).strict();
|
|
6752
|
-
var SteeringModelServingControlCommandSchema =
|
|
6753
|
-
var SteeringModelServingControlSchema =
|
|
6872
|
+
var SteeringModelServingControlCommandSchema = z59.object({ modelProjectId: Id41, request: SteeringModelServingControlRequestSchema }).strict();
|
|
6873
|
+
var SteeringModelServingControlSchema = z59.object({
|
|
6754
6874
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
6755
|
-
schemaVersion:
|
|
6875
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControl.v1"),
|
|
6756
6876
|
teamId: Id41,
|
|
6757
6877
|
modelProjectId: Id41,
|
|
6758
6878
|
versionHash: Hash45,
|
|
6759
6879
|
actorId: Id41,
|
|
6760
6880
|
operationId: Id41,
|
|
6761
|
-
revision:
|
|
6881
|
+
revision: z59.number().int().positive(),
|
|
6762
6882
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6763
|
-
desiredState:
|
|
6764
|
-
phase:
|
|
6765
|
-
capacityState:
|
|
6883
|
+
desiredState: z59.enum(["active", "stopped"]),
|
|
6884
|
+
phase: z59.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
6885
|
+
capacityState: z59.enum(["pending", "shared", "retiring", "released"]),
|
|
6766
6886
|
modelId: Id41,
|
|
6767
6887
|
poolId: Id41.nullable(),
|
|
6768
6888
|
binding: BindingRef5.nullable(),
|
|
6769
|
-
activeRequests:
|
|
6770
|
-
unsettledRequests:
|
|
6771
|
-
idleTimeoutSeconds:
|
|
6889
|
+
activeRequests: z59.number().int().nonnegative(),
|
|
6890
|
+
unsettledRequests: z59.number().int().nonnegative(),
|
|
6891
|
+
idleTimeoutSeconds: z59.number().int().min(60).max(3600),
|
|
6772
6892
|
failureCode: Id41.nullable(),
|
|
6773
6893
|
updatedAt: Timestamp6
|
|
6774
6894
|
}).strict();
|
|
6775
|
-
var SteeringServingBindingSchema =
|
|
6895
|
+
var SteeringServingBindingSchema = z59.object({
|
|
6776
6896
|
id: Id41,
|
|
6777
|
-
revision:
|
|
6897
|
+
revision: z59.number().int().positive(),
|
|
6778
6898
|
modelId: Id41,
|
|
6779
6899
|
poolId: Id41,
|
|
6780
6900
|
versionHash: Hash45
|
|
6781
6901
|
}).strict();
|
|
6782
|
-
var SteeringServingAvailabilitySchema =
|
|
6783
|
-
state:
|
|
6784
|
-
reason:
|
|
6902
|
+
var SteeringServingAvailabilitySchema = z59.object({
|
|
6903
|
+
state: z59.enum(["qualified", "unavailable"]),
|
|
6904
|
+
reason: z59.enum(["qualified", "runtime_unavailable", "calibration_unavailable", "profile_archived", "model_mismatch"]),
|
|
6785
6905
|
runtimeHash: Hash45.nullable()
|
|
6786
6906
|
}).strict();
|
|
6787
|
-
var SteeringModelServingContentSchema =
|
|
6907
|
+
var SteeringModelServingContentSchema = z59.object({
|
|
6788
6908
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
6789
|
-
schemaVersion:
|
|
6909
|
+
schemaVersion: z59.literal("openpond.steeringModelServing.v1"),
|
|
6790
6910
|
teamId: Id41,
|
|
6791
6911
|
modelProjectId: Id41,
|
|
6792
6912
|
observedAt: Timestamp6,
|
|
@@ -6794,17 +6914,17 @@ var SteeringModelServingContentSchema = z57.object({
|
|
|
6794
6914
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6795
6915
|
availability: SteeringServingAvailabilitySchema,
|
|
6796
6916
|
control: SteeringModelServingControlSchema.nullable(),
|
|
6797
|
-
cleanup:
|
|
6798
|
-
pools:
|
|
6799
|
-
bindings:
|
|
6917
|
+
cleanup: z59.array(SteeringModelServingControlSchema).max(100),
|
|
6918
|
+
pools: z59.array(TrainingServingPoolSchema).max(100),
|
|
6919
|
+
bindings: z59.array(SteeringServingBindingSchema).max(100),
|
|
6800
6920
|
lastVerifiedInference: SteeringInferenceReceiptSchema.nullable(),
|
|
6801
|
-
state:
|
|
6921
|
+
state: z59.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
6802
6922
|
}).strict();
|
|
6803
6923
|
var SteeringModelServingSchema = SteeringModelServingContentSchema.extend({ contentHash: Hash45 }).strict();
|
|
6804
|
-
var SavedModelServingSchema =
|
|
6924
|
+
var SavedModelServingSchema = z59.discriminatedUnion("schemaVersion", [TrainingModelServingSchema, SteeringModelServingSchema, EngramModelServingSchema, DecisionModelServingSchema, AlphaEditModelServingSchema, NeuronTrainingModelServingSchema]);
|
|
6805
6925
|
var SavedModelServingQuerySchema = TrainingModelServingQuerySchema;
|
|
6806
|
-
var SteeringModelServingControlReceiptContentSchema =
|
|
6807
|
-
schemaVersion:
|
|
6926
|
+
var SteeringModelServingControlReceiptContentSchema = z59.object({
|
|
6927
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControlReceipt.v1"),
|
|
6808
6928
|
teamId: Id41,
|
|
6809
6929
|
modelProjectId: Id41,
|
|
6810
6930
|
actorId: Id41,
|
|
@@ -6817,8 +6937,8 @@ function sameRef(a, b) {
|
|
|
6817
6937
|
return canonicalJson(a) === canonicalJson(b);
|
|
6818
6938
|
}
|
|
6819
6939
|
function publicationRef(version) {
|
|
6820
|
-
const { id, revision, contentHash } = version.publication;
|
|
6821
|
-
return { id, revision, contentHash };
|
|
6940
|
+
const { id, revision, contentHash: contentHash2 } = version.publication;
|
|
6941
|
+
return { id, revision, contentHash: contentHash2 };
|
|
6822
6942
|
}
|
|
6823
6943
|
function validControl5(value) {
|
|
6824
6944
|
return value.modelId === `personalized:model:${value.modelProjectId}` && (!value.binding || value.poolId !== null) && (value.phase !== "active" || value.desiredState === "active" && value.poolId !== null && value.binding !== null && ["pending", "shared"].includes(value.capacityState)) && (value.phase !== "stopping" || value.desiredState === "stopped") && (value.capacityState !== "released" || !value.binding && value.activeRequests === 0 && value.unsettledRequests === 0) && (value.phase !== "stopped" || value.desiredState === "stopped" && !value.binding && value.activeRequests === 0 && value.unsettledRequests === 0 && ["shared", "released"].includes(value.capacityState));
|
|
@@ -6834,20 +6954,20 @@ function steeringModelServingState(value) {
|
|
|
6834
6954
|
}
|
|
6835
6955
|
async function parseAndVerifySteeringModelServingControl(raw, expected) {
|
|
6836
6956
|
const value = SteeringModelServingControlReceiptSchema.parse(raw), request = SteeringModelServingControlRequestSchema.parse(expected.request);
|
|
6837
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
6957
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
6838
6958
|
await parseAndVerifySavedModelVersion(value.version, { teamId: request.teamId, modelProjectId: expected.modelProjectId });
|
|
6839
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
6959
|
+
if (!managedServingUsageApprovalMatches(request, control2) || contentHash2 !== await canonicalSha256(content) || canonicalJson(value.request) !== canonicalJson(request) || value.teamId !== request.teamId || value.modelProjectId !== expected.modelProjectId || expected.actorId && value.actorId !== expected.actorId || value.version.contentHash !== request.versionHash || request.defaultPublication !== null && !sameRef(request.defaultPublication, publicationRef(value.version)) || control2.teamId !== value.teamId || control2.modelProjectId !== value.modelProjectId || control2.actorId !== value.actorId || control2.operationId !== request.operationId || control2.versionHash !== request.versionHash || control2.revision !== request.expectedRevision + 1 || control2.idleTimeoutSeconds !== request.idleTimeoutSeconds || !sameRef(control2.defaultPublication, request.defaultPublication) || control2.desiredState !== (request.action === "activate" ? "active" : "stopped") || !validControl5(control2) || request.action === "activate" && !["starting", "active"].includes(control2.phase) || request.action === "stop" && !["stopping", "stopped"].includes(control2.phase))
|
|
6840
6960
|
throw new OpenPondProtocolError("steering_serving_control_mismatch", "The serving receipt differs from the exact saved steering Model, default or original command.");
|
|
6841
6961
|
return value;
|
|
6842
6962
|
}
|
|
6843
6963
|
async function parseAndVerifySteeringModelServing(raw, expected) {
|
|
6844
|
-
const value = SteeringModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
6964
|
+
const value = SteeringModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6845
6965
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "steering" }, value.control);
|
|
6846
6966
|
await parseAndVerifySavedModelVersion(value.version, expected);
|
|
6847
6967
|
function fail8() {
|
|
6848
6968
|
throw new OpenPondProtocolError("steering_model_serving_mismatch", "The serving evidence differs from the exact saved steering Model or retained capacity.");
|
|
6849
6969
|
}
|
|
6850
|
-
if (
|
|
6970
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || value.defaultPublication !== null && !sameRef(value.defaultPublication, publicationRef(value.version)) || value.state !== steeringModelServingState(value) || value.availability.state === "qualified" !== (value.availability.reason === "qualified") || value.availability.state === "qualified" && value.availability.runtimeHash === null) fail8();
|
|
6851
6971
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
6852
6972
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []]) {
|
|
6853
6973
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl5(control3)) fail8();
|
|
@@ -6895,18 +7015,18 @@ function createSavedModelServingClient(request) {
|
|
|
6895
7015
|
}
|
|
6896
7016
|
|
|
6897
7017
|
// src/neuron-residual-calibration.ts
|
|
6898
|
-
import { z as
|
|
6899
|
-
var Id42 =
|
|
6900
|
-
var Hash46 =
|
|
6901
|
-
var NeuronResidualCalibrationRequestSchema =
|
|
6902
|
-
schemaVersion:
|
|
7018
|
+
import { z as z60 } from "zod";
|
|
7019
|
+
var Id42 = z60.string().trim().min(1).max(500);
|
|
7020
|
+
var Hash46 = z60.string().regex(/^[a-f0-9]{64}$/);
|
|
7021
|
+
var NeuronResidualCalibrationRequestSchema = z60.object({
|
|
7022
|
+
schemaVersion: z60.literal("openpond.neuronResidualCalibrationRequest.v1"),
|
|
6903
7023
|
id: Id42,
|
|
6904
|
-
revision:
|
|
7024
|
+
revision: z60.number().int().positive(),
|
|
6905
7025
|
model: NeuronSteeringModelSchema,
|
|
6906
7026
|
prompt: ActivationReferencePromptSchema,
|
|
6907
|
-
layers:
|
|
6908
|
-
maximumForwardTokenWork:
|
|
6909
|
-
maximumDurationSeconds:
|
|
7027
|
+
layers: z60.array(z60.number().int().nonnegative().max(511)).min(1).max(512),
|
|
7028
|
+
maximumForwardTokenWork: z60.number().int().positive().max(1e6),
|
|
7029
|
+
maximumDurationSeconds: z60.number().finite().positive().max(300)
|
|
6910
7030
|
}).strict().superRefine((value, ctx) => {
|
|
6911
7031
|
if (new Set(value.layers).size !== value.layers.length || value.layers.some((layer) => layer >= value.model.intermediateSizes.length))
|
|
6912
7032
|
ctx.addIssue({ code: "custom", path: ["layers"], message: "Use unique layers inside the exact model." });
|
|
@@ -6915,13 +7035,13 @@ var NeuronResidualCalibrationRequestSchema = z58.object({
|
|
|
6915
7035
|
if (value.prompt.tokenIds.length > value.maximumForwardTokenWork)
|
|
6916
7036
|
ctx.addIssue({ code: "custom", path: ["maximumForwardTokenWork"], message: "The complete unsteered forward exceeds its declared budget." });
|
|
6917
7037
|
});
|
|
6918
|
-
var NeuronResidualCalibrationExportContentSchema =
|
|
6919
|
-
schemaVersion:
|
|
7038
|
+
var NeuronResidualCalibrationExportContentSchema = z60.object({
|
|
7039
|
+
schemaVersion: z60.literal("openpond.neuronResidualCalibrationExport.v1"),
|
|
6920
7040
|
model: NeuronSteeringModelSchema,
|
|
6921
7041
|
prompt: ActivationReferencePromptSchema,
|
|
6922
7042
|
calibration: NeuronResidualCalibrationSchema,
|
|
6923
|
-
runtime:
|
|
6924
|
-
implementation:
|
|
7043
|
+
runtime: z60.object({
|
|
7044
|
+
implementation: z60.literal("torch_dense_serial_calibration_v1"),
|
|
6925
7045
|
implementationHash: Hash46,
|
|
6926
7046
|
torchVersion: Id42,
|
|
6927
7047
|
device: Id42
|
|
@@ -6929,10 +7049,10 @@ var NeuronResidualCalibrationExportContentSchema = z58.object({
|
|
|
6929
7049
|
}).strict();
|
|
6930
7050
|
var NeuronResidualCalibrationExportSchema = NeuronResidualCalibrationExportContentSchema.extend({ contentHash: Hash46 }).strict();
|
|
6931
7051
|
async function parseAndVerifyNeuronResidualCalibrationExport(raw, expected) {
|
|
6932
|
-
const value = NeuronResidualCalibrationExportSchema.parse(raw), { contentHash, ...content } = value;
|
|
7052
|
+
const value = NeuronResidualCalibrationExportSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6933
7053
|
const calibration = await parseAndVerifyNeuronResidualCalibration(value.calibration, value.model);
|
|
6934
7054
|
const sourceHash = await canonicalSha256(value.prompt), samples = value.prompt.attentionMask.filter(Boolean).length - 1;
|
|
6935
|
-
let mismatch2 =
|
|
7055
|
+
let mismatch2 = contentHash2 !== await canonicalSha256(content) || samples <= 0 || calibration.source.id !== value.prompt.id || calibration.source.contentHash !== sourceHash || calibration.layers.some((layer) => layer.sampleCount !== samples);
|
|
6936
7056
|
if (expected) {
|
|
6937
7057
|
const request = NeuronResidualCalibrationRequestSchema.parse(expected);
|
|
6938
7058
|
mismatch2 ||= canonicalJson(value.model) !== canonicalJson(request.model) || canonicalJson(value.prompt) !== canonicalJson(request.prompt) || calibration.id !== request.id || calibration.revision !== request.revision || canonicalJson(calibration.layers.map((row) => row.layer).sort((a, b) => a - b)) !== canonicalJson([...request.layers].sort((a, b) => a - b));
|
|
@@ -6942,40 +7062,40 @@ async function parseAndVerifyNeuronResidualCalibrationExport(raw, expected) {
|
|
|
6942
7062
|
}
|
|
6943
7063
|
|
|
6944
7064
|
// src/neuron-calibration-records.ts
|
|
6945
|
-
import { z as
|
|
6946
|
-
var Id43 =
|
|
6947
|
-
var Hash47 =
|
|
6948
|
-
var Name2 =
|
|
6949
|
-
var Timestamp7 =
|
|
6950
|
-
var NeuronCalibrationRecordContentSchema =
|
|
6951
|
-
schemaVersion:
|
|
7065
|
+
import { z as z61 } from "zod";
|
|
7066
|
+
var Id43 = z61.string().trim().min(1).max(500);
|
|
7067
|
+
var Hash47 = z61.string().regex(/^[a-f0-9]{64}$/);
|
|
7068
|
+
var Name2 = z61.string().trim().min(1).max(200);
|
|
7069
|
+
var Timestamp7 = z61.iso.datetime();
|
|
7070
|
+
var NeuronCalibrationRecordContentSchema = z61.object({
|
|
7071
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationRecord.v1"),
|
|
6952
7072
|
teamId: Id43,
|
|
6953
7073
|
ownerUserId: Id43,
|
|
6954
7074
|
projectId: Id43.nullable(),
|
|
6955
7075
|
name: Name2,
|
|
6956
7076
|
artifact: NeuronResidualCalibrationExportSchema,
|
|
6957
|
-
revision:
|
|
6958
|
-
archived:
|
|
7077
|
+
revision: z61.number().int().positive(),
|
|
7078
|
+
archived: z61.boolean(),
|
|
6959
7079
|
createdAt: Timestamp7,
|
|
6960
7080
|
updatedAt: Timestamp7
|
|
6961
7081
|
}).strict();
|
|
6962
7082
|
var NeuronCalibrationRecordSchema = NeuronCalibrationRecordContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
6963
|
-
var NeuronCalibrationImportRequestSchema =
|
|
7083
|
+
var NeuronCalibrationImportRequestSchema = z61.object({
|
|
6964
7084
|
teamId: Id43,
|
|
6965
7085
|
operationId: Id43,
|
|
6966
7086
|
projectId: Id43.nullable(),
|
|
6967
7087
|
name: Name2,
|
|
6968
7088
|
artifact: NeuronResidualCalibrationExportSchema
|
|
6969
7089
|
}).strict();
|
|
6970
|
-
var NeuronCalibrationReadQuerySchema =
|
|
6971
|
-
var NeuronCalibrationArchiveRequestSchema =
|
|
7090
|
+
var NeuronCalibrationReadQuerySchema = z61.object({ teamId: Id43 }).strict();
|
|
7091
|
+
var NeuronCalibrationArchiveRequestSchema = z61.object({
|
|
6972
7092
|
teamId: Id43,
|
|
6973
7093
|
operationId: Id43,
|
|
6974
|
-
expectedRevision:
|
|
7094
|
+
expectedRevision: z61.number().int().positive(),
|
|
6975
7095
|
contentHash: Hash47
|
|
6976
7096
|
}).strict();
|
|
6977
|
-
var NeuronCalibrationReceiptContentSchema =
|
|
6978
|
-
schemaVersion:
|
|
7097
|
+
var NeuronCalibrationReceiptContentSchema = z61.object({
|
|
7098
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationReceipt.v1"),
|
|
6979
7099
|
teamId: Id43,
|
|
6980
7100
|
actorId: Id43,
|
|
6981
7101
|
operationId: Id43,
|
|
@@ -6983,14 +7103,14 @@ var NeuronCalibrationReceiptContentSchema = z59.object({
|
|
|
6983
7103
|
record: NeuronCalibrationRecordSchema
|
|
6984
7104
|
}).strict();
|
|
6985
7105
|
var NeuronCalibrationReceiptSchema = NeuronCalibrationReceiptContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
6986
|
-
var NeuronCalibrationListQuerySchema =
|
|
7106
|
+
var NeuronCalibrationListQuerySchema = z61.object({
|
|
6987
7107
|
projectId: Id43.optional(),
|
|
6988
7108
|
modelHash: Hash47.optional(),
|
|
6989
|
-
archived:
|
|
6990
|
-
limit:
|
|
6991
|
-
cursor:
|
|
7109
|
+
archived: z61.boolean().default(false),
|
|
7110
|
+
limit: z61.number().int().min(1).max(100).default(25),
|
|
7111
|
+
cursor: z61.string().min(1).max(2048).optional()
|
|
6992
7112
|
}).strict();
|
|
6993
|
-
var NeuronCalibrationSummarySchema =
|
|
7113
|
+
var NeuronCalibrationSummarySchema = z61.object({
|
|
6994
7114
|
reference: NeuronSteeringReferenceSchema,
|
|
6995
7115
|
teamId: Id43,
|
|
6996
7116
|
ownerUserId: Id43,
|
|
@@ -6998,36 +7118,36 @@ var NeuronCalibrationSummarySchema = z59.object({
|
|
|
6998
7118
|
name: Name2,
|
|
6999
7119
|
exportHash: Hash47,
|
|
7000
7120
|
modelHash: Hash47,
|
|
7001
|
-
source:
|
|
7121
|
+
source: z61.object({ id: Id43, contentHash: Hash47 }).strict(),
|
|
7002
7122
|
implementationHash: Hash47,
|
|
7003
|
-
layerCount:
|
|
7004
|
-
revision:
|
|
7005
|
-
archived:
|
|
7123
|
+
layerCount: z61.number().int().min(1).max(512),
|
|
7124
|
+
revision: z61.number().int().positive(),
|
|
7125
|
+
archived: z61.boolean(),
|
|
7006
7126
|
createdAt: Timestamp7,
|
|
7007
7127
|
updatedAt: Timestamp7
|
|
7008
7128
|
}).strict();
|
|
7009
|
-
var NeuronCalibrationPageContentSchema =
|
|
7010
|
-
schemaVersion:
|
|
7129
|
+
var NeuronCalibrationPageContentSchema = z61.object({
|
|
7130
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationPage.v1"),
|
|
7011
7131
|
teamId: Id43,
|
|
7012
7132
|
ownerUserId: Id43,
|
|
7013
7133
|
query: NeuronCalibrationListQuerySchema,
|
|
7014
|
-
items:
|
|
7015
|
-
nextCursor:
|
|
7134
|
+
items: z61.array(NeuronCalibrationSummarySchema).max(100),
|
|
7135
|
+
nextCursor: z61.string().min(1).max(2048).nullable()
|
|
7016
7136
|
}).strict();
|
|
7017
7137
|
var NeuronCalibrationPageSchema = NeuronCalibrationPageContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
7018
7138
|
async function parseAndVerifyNeuronCalibrationRecord(raw, expected = {}) {
|
|
7019
|
-
const value = NeuronCalibrationRecordSchema.parse(raw), { contentHash, ...content } = value;
|
|
7139
|
+
const value = NeuronCalibrationRecordSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7020
7140
|
await parseAndVerifyNeuronResidualCalibrationExport(value.artifact);
|
|
7021
|
-
if (
|
|
7141
|
+
if (contentHash2 !== await canonicalSha256(content) || expected.teamId && value.teamId !== expected.teamId || expected.ownerUserId && value.ownerUserId !== expected.ownerUserId || expected.id && value.artifact.calibration.id !== expected.id)
|
|
7022
7142
|
throw new OpenPondProtocolError("neuron_calibration_record_mismatch", "The original calibration record differs from its artifact or authorized workspace.");
|
|
7023
7143
|
return value;
|
|
7024
7144
|
}
|
|
7025
7145
|
async function parseAndVerifyNeuronCalibrationReceipt(raw, request, id) {
|
|
7026
|
-
const value = NeuronCalibrationReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
7146
|
+
const value = NeuronCalibrationReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7027
7147
|
const importing = "artifact" in request;
|
|
7028
7148
|
const parsed = importing ? NeuronCalibrationImportRequestSchema.parse(request) : NeuronCalibrationArchiveRequestSchema.parse(request);
|
|
7029
7149
|
await parseAndVerifyNeuronCalibrationRecord(value.record, { teamId: parsed.teamId, ownerUserId: value.actorId, id });
|
|
7030
|
-
if (
|
|
7150
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== parsed.teamId || value.operationId !== parsed.operationId || value.requestHash !== await canonicalSha256(importing ? parsed : { id, request: parsed }))
|
|
7031
7151
|
throw new OpenPondProtocolError("neuron_calibration_receipt_mismatch", "Retry the original calibration custody command.");
|
|
7032
7152
|
if ("artifact" in parsed) {
|
|
7033
7153
|
if (canonicalJson(value.record.artifact) !== canonicalJson(parsed.artifact) || value.record.projectId !== parsed.projectId || value.record.name !== parsed.name || value.record.archived || value.record.revision !== 1)
|
|
@@ -7061,8 +7181,8 @@ function createNeuronCalibrationClient(request) {
|
|
|
7061
7181
|
async listNeuronCalibrations(teamId, raw = {}) {
|
|
7062
7182
|
const scope2 = Id43.parse(teamId), query = Object.fromEntries(Object.entries(NeuronCalibrationListQuerySchema.parse(raw)).filter(([, value]) => value !== void 0)), params5 = new URLSearchParams({ teamId: scope2 });
|
|
7063
7183
|
for (const [key, value] of Object.entries(query)) if (value !== void 0) params5.set(key, String(value));
|
|
7064
|
-
const page = NeuronCalibrationPageSchema.parse(await request(`/v1/training/neuron-calibrations?${params5}`)), { contentHash, ...content } = page;
|
|
7065
|
-
if (page.teamId !== scope2 || canonicalJson(page.query) !== canonicalJson(query) ||
|
|
7184
|
+
const page = NeuronCalibrationPageSchema.parse(await request(`/v1/training/neuron-calibrations?${params5}`)), { contentHash: contentHash2, ...content } = page;
|
|
7185
|
+
if (page.teamId !== scope2 || canonicalJson(page.query) !== canonicalJson(query) || contentHash2 !== await canonicalSha256(content) || page.items.length > query.limit || new Set(page.items.map((row) => row.reference.id)).size !== page.items.length || page.nextCursor !== null && (page.items.length !== query.limit || page.nextCursor === query.cursor))
|
|
7066
7186
|
throw new OpenPondProtocolError("neuron_calibration_page_mismatch", "Refresh calibration history in its original workspace.");
|
|
7067
7187
|
for (const [index, row] of page.items.entries()) if (row.teamId !== scope2 || row.ownerUserId !== page.ownerUserId || row.archived !== query.archived || query.projectId && row.projectId !== query.projectId || query.modelHash && row.modelHash !== query.modelHash || index && page.items[index - 1].reference.id >= row.reference.id)
|
|
7068
7188
|
throw new OpenPondProtocolError("neuron_calibration_page_mismatch", "Calibration history returned a different creator or source scope.");
|
|
@@ -7185,64 +7305,64 @@ async function verifyAndCompareActivationReferenceResult(request, raw, reference
|
|
|
7185
7305
|
}
|
|
7186
7306
|
|
|
7187
7307
|
// src/modification-recordings.ts
|
|
7188
|
-
import { z as
|
|
7189
|
-
var Id44 =
|
|
7190
|
-
var Hash48 =
|
|
7308
|
+
import { z as z62 } from "zod";
|
|
7309
|
+
var Id44 = z62.string().trim().min(1).max(240);
|
|
7310
|
+
var Hash48 = z62.string().regex(/^[a-f0-9]{64}$/);
|
|
7191
7311
|
var MODIFICATION_RECORDING_MAX_BYTES = 8388608;
|
|
7192
|
-
var ModificationRecordingRequestSchema =
|
|
7193
|
-
schemaVersion:
|
|
7312
|
+
var ModificationRecordingRequestSchema = z62.object({
|
|
7313
|
+
schemaVersion: z62.literal("openpond.modificationRecordingRequest.v1"),
|
|
7194
7314
|
teamId: Id44,
|
|
7195
7315
|
operationId: Id44,
|
|
7196
|
-
name:
|
|
7316
|
+
name: z62.string().trim().min(1).max(500),
|
|
7197
7317
|
projectId: Id44.nullable(),
|
|
7198
7318
|
method: ModelModificationMethodSchema,
|
|
7199
7319
|
request: ActivationReferenceRequestSchema,
|
|
7200
7320
|
result: ActivationReferenceResultSchema
|
|
7201
7321
|
}).strict();
|
|
7202
|
-
var ModificationRecordingContentSchema =
|
|
7203
|
-
schemaVersion:
|
|
7322
|
+
var ModificationRecordingContentSchema = z62.object({
|
|
7323
|
+
schemaVersion: z62.literal("openpond.modificationRecording.v1"),
|
|
7204
7324
|
id: Id44,
|
|
7205
7325
|
teamId: Id44,
|
|
7206
7326
|
actorId: Id44,
|
|
7207
7327
|
operationId: Id44,
|
|
7208
7328
|
commandHash: Hash48,
|
|
7209
|
-
name:
|
|
7329
|
+
name: z62.string().trim().min(1).max(500),
|
|
7210
7330
|
projectId: Id44.nullable(),
|
|
7211
7331
|
method: ModelModificationMethodSchema,
|
|
7212
7332
|
accountScopeHash: Hash48,
|
|
7213
|
-
custody:
|
|
7214
|
-
provenance:
|
|
7215
|
-
measurementAttestation:
|
|
7333
|
+
custody: z62.literal("local"),
|
|
7334
|
+
provenance: z62.literal("external_observation"),
|
|
7335
|
+
measurementAttestation: z62.literal("unattested"),
|
|
7216
7336
|
model: ActivationReferenceRequestSchema.shape.model,
|
|
7217
7337
|
inputHash: Hash48,
|
|
7218
7338
|
resultHash: Hash48,
|
|
7219
|
-
artifact:
|
|
7220
|
-
counts:
|
|
7221
|
-
prompts:
|
|
7222
|
-
variants:
|
|
7223
|
-
outcomes:
|
|
7224
|
-
captures:
|
|
7339
|
+
artifact: z62.object({ contentHash: Hash48, sizeBytes: z62.number().int().positive().max(MODIFICATION_RECORDING_MAX_BYTES) }).strict(),
|
|
7340
|
+
counts: z62.object({
|
|
7341
|
+
prompts: z62.number().int().positive().max(8),
|
|
7342
|
+
variants: z62.number().int().positive().max(17),
|
|
7343
|
+
outcomes: z62.number().int().positive().max(136),
|
|
7344
|
+
captures: z62.number().int().nonnegative().max(32768)
|
|
7225
7345
|
}).strict(),
|
|
7226
|
-
createdAt:
|
|
7346
|
+
createdAt: z62.iso.datetime()
|
|
7227
7347
|
}).strict();
|
|
7228
7348
|
var ModificationRecordingSchema = ModificationRecordingContentSchema.extend({ contentHash: Hash48 }).strict();
|
|
7229
|
-
var ModificationRecordingDocumentSchema =
|
|
7230
|
-
var ModificationRecordingReadSchema =
|
|
7231
|
-
var ModificationRecordingReadQuerySchema =
|
|
7232
|
-
var ModificationRecordingListQuerySchema =
|
|
7349
|
+
var ModificationRecordingDocumentSchema = z62.object({ request: ActivationReferenceRequestSchema, result: ActivationReferenceResultSchema }).strict();
|
|
7350
|
+
var ModificationRecordingReadSchema = z62.object({ recording: ModificationRecordingSchema, document: ModificationRecordingDocumentSchema }).strict();
|
|
7351
|
+
var ModificationRecordingReadQuerySchema = z62.object({ teamId: Id44 }).strict();
|
|
7352
|
+
var ModificationRecordingListQuerySchema = z62.object({
|
|
7233
7353
|
teamId: Id44,
|
|
7234
7354
|
projectId: Id44.optional(),
|
|
7235
|
-
search:
|
|
7236
|
-
cursor:
|
|
7237
|
-
limit:
|
|
7355
|
+
search: z62.string().trim().max(1e3).optional(),
|
|
7356
|
+
cursor: z62.string().min(1).max(2e3).optional(),
|
|
7357
|
+
limit: z62.number().int().min(1).max(100).default(30)
|
|
7238
7358
|
}).strict();
|
|
7239
|
-
var ModificationRecordingPageSchema =
|
|
7359
|
+
var ModificationRecordingPageSchema = z62.object({
|
|
7240
7360
|
teamId: Id44,
|
|
7241
7361
|
actorId: Id44,
|
|
7242
7362
|
accountScopeHash: Hash48,
|
|
7243
7363
|
projectId: Id44.nullable(),
|
|
7244
|
-
items:
|
|
7245
|
-
nextCursor:
|
|
7364
|
+
items: z62.array(ModificationRecordingSchema).max(100),
|
|
7365
|
+
nextCursor: z62.string().min(1).max(2e3).nullable()
|
|
7246
7366
|
}).strict();
|
|
7247
7367
|
async function verifyModificationRecordingRequest(raw) {
|
|
7248
7368
|
const value = ModificationRecordingRequestSchema.parse(raw);
|
|
@@ -7256,8 +7376,8 @@ async function verifyModificationRecordingRequest(raw) {
|
|
|
7256
7376
|
return value;
|
|
7257
7377
|
}
|
|
7258
7378
|
async function verifyModificationRecording(raw, teamId, actorId) {
|
|
7259
|
-
const value = ModificationRecordingSchema.parse(raw), { contentHash, ...content } = value;
|
|
7260
|
-
if (
|
|
7379
|
+
const value = ModificationRecordingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7380
|
+
if (contentHash2 !== await canonicalSha256(content) || teamId !== void 0 && value.teamId !== teamId || actorId !== void 0 && value.actorId !== actorId || value.id !== `observation-${await canonicalSha256({ scope: value.accountScopeHash, operationId: value.operationId })}` || value.counts.outcomes !== value.counts.prompts * value.counts.variants)
|
|
7261
7381
|
throw new OpenPondProtocolError("modification_recording_scope_mismatch", "The retained recording differs from its owner or immutable metadata.");
|
|
7262
7382
|
return value;
|
|
7263
7383
|
}
|
|
@@ -7313,37 +7433,37 @@ function createModificationRecordingsClient(request) {
|
|
|
7313
7433
|
}
|
|
7314
7434
|
|
|
7315
7435
|
// src/training-hardware-catalog.ts
|
|
7316
|
-
import { z as
|
|
7317
|
-
var OpaqueIdentifier =
|
|
7318
|
-
var TrainingHardwareSpecificationSchema =
|
|
7319
|
-
id:
|
|
7320
|
-
name:
|
|
7321
|
-
manufacturer:
|
|
7322
|
-
memoryGb:
|
|
7323
|
-
secureCloud:
|
|
7324
|
-
communityCloud:
|
|
7325
|
-
maximumPerPod:
|
|
7326
|
-
secure:
|
|
7327
|
-
community:
|
|
7436
|
+
import { z as z63 } from "zod";
|
|
7437
|
+
var OpaqueIdentifier = z63.string().min(1).max(191).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/);
|
|
7438
|
+
var TrainingHardwareSpecificationSchema = z63.object({
|
|
7439
|
+
id: z63.string().trim().min(1).max(256),
|
|
7440
|
+
name: z63.string().trim().min(1).max(256),
|
|
7441
|
+
manufacturer: z63.string().trim().min(1).max(100),
|
|
7442
|
+
memoryGb: z63.number().int().positive(),
|
|
7443
|
+
secureCloud: z63.boolean(),
|
|
7444
|
+
communityCloud: z63.boolean(),
|
|
7445
|
+
maximumPerPod: z63.object({
|
|
7446
|
+
secure: z63.number().int().nonnegative(),
|
|
7447
|
+
community: z63.number().int().nonnegative()
|
|
7328
7448
|
}).strict()
|
|
7329
7449
|
}).strict();
|
|
7330
|
-
var TrainingHardwareInventorySchema =
|
|
7331
|
-
schemaVersion:
|
|
7450
|
+
var TrainingHardwareInventorySchema = z63.object({
|
|
7451
|
+
schemaVersion: z63.literal("openpond.trainingHardwareInventory.v1"),
|
|
7332
7452
|
provider: OpaqueIdentifier,
|
|
7333
7453
|
source: OpaqueIdentifier,
|
|
7334
|
-
version:
|
|
7335
|
-
observedAt:
|
|
7336
|
-
refreshAfter:
|
|
7337
|
-
hardware:
|
|
7454
|
+
version: z63.string().regex(/^[a-f0-9]{64}$/),
|
|
7455
|
+
observedAt: z63.iso.datetime(),
|
|
7456
|
+
refreshAfter: z63.iso.datetime(),
|
|
7457
|
+
hardware: z63.array(TrainingHardwareSpecificationSchema).max(1e3)
|
|
7338
7458
|
}).strict();
|
|
7339
|
-
var TrainingHardwareCatalogSchema =
|
|
7340
|
-
schemaVersion:
|
|
7459
|
+
var TrainingHardwareCatalogSchema = z63.object({
|
|
7460
|
+
schemaVersion: z63.literal("openpond.trainingHardwareCatalog.v1"),
|
|
7341
7461
|
inventory: TrainingHardwareInventorySchema,
|
|
7342
|
-
workerImageDigest:
|
|
7343
|
-
eligibility:
|
|
7344
|
-
gpuTypeId:
|
|
7345
|
-
status:
|
|
7346
|
-
reason:
|
|
7462
|
+
workerImageDigest: z63.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
7463
|
+
eligibility: z63.array(z63.object({
|
|
7464
|
+
gpuTypeId: z63.string().min(1).max(256),
|
|
7465
|
+
status: z63.enum(["requires_live_workload_check", "not_admitted"]),
|
|
7466
|
+
reason: z63.enum(["candidate_for_current_runtime", "gpu_type_not_enabled", "secure_pods_unavailable", "insufficient_memory"])
|
|
7347
7467
|
}).strict()).max(1e3)
|
|
7348
7468
|
}).strict();
|
|
7349
7469
|
async function parseAndVerifyTrainingHardwareInventory(raw) {
|
|
@@ -7370,12 +7490,12 @@ function createTrainingHardwareCatalogClient(request) {
|
|
|
7370
7490
|
}
|
|
7371
7491
|
|
|
7372
7492
|
// src/training-harness-sources.ts
|
|
7373
|
-
import { z as
|
|
7374
|
-
var TrainingHarnessSourcePublicationSchema =
|
|
7375
|
-
schemaVersion:
|
|
7493
|
+
import { z as z64 } from "zod";
|
|
7494
|
+
var TrainingHarnessSourcePublicationSchema = z64.object({
|
|
7495
|
+
schemaVersion: z64.literal("openpond.trainingHarnessSourcePublication.v1"),
|
|
7376
7496
|
harnessRelease: ImmutableReleaseRefSchema,
|
|
7377
|
-
sourcePackageHash:
|
|
7378
|
-
sizeBytes:
|
|
7497
|
+
sourcePackageHash: z64.string().regex(/^[a-f0-9]{64}$/),
|
|
7498
|
+
sizeBytes: z64.number().int().positive().max(TRAINING_INPUT_ARTIFACT_MAX_BYTES)
|
|
7379
7499
|
}).strict();
|
|
7380
7500
|
function createTrainingHarnessSourceClient(request) {
|
|
7381
7501
|
const route = (reference) => {
|
|
@@ -7408,28 +7528,28 @@ function validateSource(value, reference) {
|
|
|
7408
7528
|
}
|
|
7409
7529
|
|
|
7410
7530
|
// src/training-candidate-decisions.ts
|
|
7411
|
-
import { z as
|
|
7412
|
-
var IdSchema = /* @__PURE__ */ (() =>
|
|
7413
|
-
var HashSchema = /* @__PURE__ */ (() =>
|
|
7414
|
-
var TrainingCandidateDecisionRequestSchema = /* @__PURE__ */ (() =>
|
|
7415
|
-
schemaVersion:
|
|
7531
|
+
import { z as z65 } from "zod";
|
|
7532
|
+
var IdSchema = /* @__PURE__ */ (() => z65.string().trim().min(1).max(500))();
|
|
7533
|
+
var HashSchema = /* @__PURE__ */ (() => z65.string().regex(/^[a-f0-9]{64}$/))();
|
|
7534
|
+
var TrainingCandidateDecisionRequestSchema = /* @__PURE__ */ (() => z65.object({
|
|
7535
|
+
schemaVersion: z65.literal("openpond.trainingCandidateDecisionRequest.v1"),
|
|
7416
7536
|
teamId: IdSchema,
|
|
7417
7537
|
jobId: IdSchema,
|
|
7418
7538
|
artifact: ModelProjectImmutableRefSchema,
|
|
7419
7539
|
evaluation: ModelProjectImmutableRefSchema,
|
|
7420
7540
|
executionReceipt: ModelProjectImmutableRefSchema,
|
|
7421
|
-
decision:
|
|
7422
|
-
reason:
|
|
7541
|
+
decision: z65.enum(["accepted", "rejected"]),
|
|
7542
|
+
reason: z65.string().trim().min(1).max(5e3),
|
|
7423
7543
|
idempotencyKey: IdSchema,
|
|
7424
7544
|
expectedDecision: ModelProjectImmutableRefSchema.nullable()
|
|
7425
7545
|
}).strict())();
|
|
7426
|
-
var TrainingCandidateDecisionSchema = /* @__PURE__ */ (() =>
|
|
7427
|
-
schemaVersion:
|
|
7546
|
+
var TrainingCandidateDecisionSchema = /* @__PURE__ */ (() => z65.object({
|
|
7547
|
+
schemaVersion: z65.literal("openpond.trainingCandidateDecision.v1"),
|
|
7428
7548
|
id: IdSchema,
|
|
7429
7549
|
request: TrainingCandidateDecisionRequestSchema,
|
|
7430
|
-
revision:
|
|
7431
|
-
actor:
|
|
7432
|
-
decidedAt:
|
|
7550
|
+
revision: z65.number().int().positive(),
|
|
7551
|
+
actor: z65.object({ userId: IdSchema, kind: z65.enum(["user", "api_key", "agent_delegate"]), id: IdSchema }).strict(),
|
|
7552
|
+
decidedAt: z65.string().datetime({ offset: true }),
|
|
7433
7553
|
contentHash: HashSchema
|
|
7434
7554
|
}).strict().superRefine((value, context) => {
|
|
7435
7555
|
if (value.revision === 1 !== (value.request.expectedDecision === null)) {
|
|
@@ -7466,7 +7586,7 @@ function createTrainingCandidateDecisionClient(request) {
|
|
|
7466
7586
|
IdSchema.parse(target.teamId);
|
|
7467
7587
|
const reference = options.decision ? ModelProjectImmutableRefSchema.parse(options.decision) : void 0;
|
|
7468
7588
|
const query = reference ? `?decisionId=${encodeURIComponent(reference.id)}` : "";
|
|
7469
|
-
const response =
|
|
7589
|
+
const response = z65.object({ decision: z65.unknown().nullable() }).strict().parse(await request(`${route(target)}${query}`));
|
|
7470
7590
|
if (response.decision === null && !reference) return null;
|
|
7471
7591
|
const decision = await parseAndVerifyTrainingCandidateDecision(response.decision, target);
|
|
7472
7592
|
if (reference && (decision.id !== reference.id || decision.contentHash !== reference.contentHash)) {
|
|
@@ -7483,38 +7603,38 @@ function createTrainingCandidateDecisionClient(request) {
|
|
|
7483
7603
|
}
|
|
7484
7604
|
|
|
7485
7605
|
// src/training-evaluation-results.ts
|
|
7486
|
-
import { z as
|
|
7487
|
-
var IdSchema2 = /* @__PURE__ */ (() =>
|
|
7488
|
-
var HashSchema2 = /* @__PURE__ */ (() =>
|
|
7489
|
-
var TrainingEvaluationTaskResultSchema = /* @__PURE__ */ (() =>
|
|
7606
|
+
import { z as z66 } from "zod";
|
|
7607
|
+
var IdSchema2 = /* @__PURE__ */ (() => z66.string().trim().min(1).max(500))();
|
|
7608
|
+
var HashSchema2 = /* @__PURE__ */ (() => z66.string().regex(/^[a-f0-9]{64}$/))();
|
|
7609
|
+
var TrainingEvaluationTaskResultSchema = /* @__PURE__ */ (() => z66.object({
|
|
7490
7610
|
taskId: IdSchema2,
|
|
7491
7611
|
taskSha256: HashSchema2,
|
|
7492
7612
|
resultSha256: HashSchema2,
|
|
7493
|
-
input:
|
|
7494
|
-
instruction:
|
|
7495
|
-
context:
|
|
7613
|
+
input: z66.object({
|
|
7614
|
+
instruction: z66.string().max(1e6),
|
|
7615
|
+
context: z66.record(z66.string(), z66.unknown())
|
|
7496
7616
|
}).strict(),
|
|
7497
|
-
output:
|
|
7617
|
+
output: z66.string().max(1e6),
|
|
7498
7618
|
outputSha256: HashSchema2,
|
|
7499
|
-
score:
|
|
7500
|
-
evidence:
|
|
7501
|
-
kind:
|
|
7619
|
+
score: z66.number().finite().min(0).max(1),
|
|
7620
|
+
evidence: z66.object({
|
|
7621
|
+
kind: z66.enum(["worker_command", "hosted_trace", "local_trace"]),
|
|
7502
7622
|
id: IdSchema2
|
|
7503
7623
|
}).strict()
|
|
7504
7624
|
}).strict())();
|
|
7505
|
-
var TrainingEvaluationTaskPageSchema = /* @__PURE__ */ (() =>
|
|
7506
|
-
schemaVersion:
|
|
7625
|
+
var TrainingEvaluationTaskPageSchema = /* @__PURE__ */ (() => z66.object({
|
|
7626
|
+
schemaVersion: z66.literal("openpond.trainingEvaluationTaskPage.v1"),
|
|
7507
7627
|
jobId: IdSchema2,
|
|
7508
7628
|
teamId: IdSchema2,
|
|
7509
7629
|
evaluation: ModelProjectImmutableRefSchema,
|
|
7510
|
-
kind:
|
|
7511
|
-
policyVersion:
|
|
7630
|
+
kind: z66.enum(["baseline", "candidate"]),
|
|
7631
|
+
policyVersion: z66.number().int().nonnegative(),
|
|
7512
7632
|
taskset: ModelProjectVersionedRefSchema,
|
|
7513
7633
|
panelSha256: HashSchema2,
|
|
7514
|
-
offset:
|
|
7515
|
-
total:
|
|
7516
|
-
tasks:
|
|
7517
|
-
nextCursor:
|
|
7634
|
+
offset: z66.number().int().nonnegative(),
|
|
7635
|
+
total: z66.number().int().min(1).max(1e4),
|
|
7636
|
+
tasks: z66.array(TrainingEvaluationTaskResultSchema).min(1).max(100),
|
|
7637
|
+
nextCursor: z66.string().regex(/^[1-9]\d*$/).nullable(),
|
|
7518
7638
|
contentHash: HashSchema2
|
|
7519
7639
|
}).strict().superRefine((page, context) => {
|
|
7520
7640
|
const end = page.offset + page.tasks.length;
|
|
@@ -7720,13 +7840,14 @@ async function experimentStartingModelFromSteeringVersion(resolved, options = {}
|
|
|
7720
7840
|
}
|
|
7721
7841
|
|
|
7722
7842
|
// src/training.ts
|
|
7723
|
-
var IdSchema3 =
|
|
7843
|
+
var IdSchema3 = z67.string().trim().min(1).max(500);
|
|
7724
7844
|
function createTrainingClient(input) {
|
|
7725
7845
|
const request = createTrainingRequest(input);
|
|
7726
7846
|
return {
|
|
7727
7847
|
postTraining: createPostTrainingClient({ request }),
|
|
7728
7848
|
...createTrainingPreparationClient(request),
|
|
7729
7849
|
...createTrainingExperimentSetupClient(request),
|
|
7850
|
+
...createTrainingExperimentLearningClient(request),
|
|
7730
7851
|
...createTrainingEstimateClient(request),
|
|
7731
7852
|
...createTrainingFundingClient(request),
|
|
7732
7853
|
...createDatasetTrainingReviewClient(request),
|
|
@@ -7795,10 +7916,10 @@ function createTrainingClient(input) {
|
|
|
7795
7916
|
parameters.set("modelProjectId", IdSchema3.parse(options.modelProjectId));
|
|
7796
7917
|
}
|
|
7797
7918
|
if (options.cursor) {
|
|
7798
|
-
parameters.set("cursor",
|
|
7919
|
+
parameters.set("cursor", z67.string().trim().min(1).max(2e3).parse(options.cursor));
|
|
7799
7920
|
}
|
|
7800
7921
|
if (options.limit !== void 0) {
|
|
7801
|
-
parameters.set("limit", String(
|
|
7922
|
+
parameters.set("limit", String(z67.number().int().min(1).max(1e3).parse(options.limit)));
|
|
7802
7923
|
}
|
|
7803
7924
|
const query = parameters.size > 0 ? `?${parameters.toString()}` : "";
|
|
7804
7925
|
return TrainingJobPageSchema.parse(await request(`/v1/training/jobs${query}`));
|
|
@@ -7848,7 +7969,7 @@ function createTrainingClient(input) {
|
|
|
7848
7969
|
), "job"));
|
|
7849
7970
|
},
|
|
7850
7971
|
async events(jobId) {
|
|
7851
|
-
return
|
|
7972
|
+
return z67.array(TrainingJobEventSchema).parse(
|
|
7852
7973
|
unwrapObject(
|
|
7853
7974
|
await request(`/v1/training/jobs/${encodeURIComponent(IdSchema3.parse(jobId))}/events`),
|
|
7854
7975
|
"events"
|
|
@@ -7864,11 +7985,11 @@ function createTrainingClient(input) {
|
|
|
7864
7985
|
const id = IdSchema3.parse(jobId);
|
|
7865
7986
|
const reference = ModelProjectImmutableRefSchema.parse(evaluation);
|
|
7866
7987
|
const parameters = new URLSearchParams();
|
|
7867
|
-
const cursor = options.cursor === void 0 ? void 0 :
|
|
7868
|
-
const offset = cursor === void 0 ? 0 :
|
|
7988
|
+
const cursor = options.cursor === void 0 ? void 0 : z67.string().regex(/^[1-9]\d*$/).parse(options.cursor);
|
|
7989
|
+
const offset = cursor === void 0 ? 0 : z67.number().int().min(1).max(9999).parse(Number(cursor));
|
|
7869
7990
|
if (cursor !== void 0) parameters.set("cursor", cursor);
|
|
7870
7991
|
if (options.limit !== void 0)
|
|
7871
|
-
parameters.set("limit", String(
|
|
7992
|
+
parameters.set("limit", String(z67.number().int().min(1).max(100).parse(options.limit)));
|
|
7872
7993
|
const query = parameters.size ? `?${parameters.toString()}` : "";
|
|
7873
7994
|
return parseAndVerifyTrainingEvaluationTaskPage(
|
|
7874
7995
|
await request(
|
|
@@ -7878,7 +7999,7 @@ function createTrainingClient(input) {
|
|
|
7878
7999
|
);
|
|
7879
8000
|
},
|
|
7880
8001
|
async logs(jobId) {
|
|
7881
|
-
return
|
|
8002
|
+
return z67.array(TrainingJobLogSchema).max(1e5).parse(
|
|
7882
8003
|
unwrapObject(
|
|
7883
8004
|
await request(`/v1/training/jobs/${encodeURIComponent(IdSchema3.parse(jobId))}/logs`),
|
|
7884
8005
|
"logs"
|
|
@@ -8332,6 +8453,9 @@ export {
|
|
|
8332
8453
|
TrainingExecutionSummarySchema,
|
|
8333
8454
|
TrainingExperimentFormDraftSchema,
|
|
8334
8455
|
TrainingExperimentInputsPageSchema,
|
|
8456
|
+
TrainingExperimentLearningIntentSchema,
|
|
8457
|
+
TrainingExperimentLearningReceiptSchema,
|
|
8458
|
+
TrainingExperimentLearningRequestSchema,
|
|
8335
8459
|
TrainingExperimentSetupReceiptSchema,
|
|
8336
8460
|
TrainingExperimentSetupRequestSchema,
|
|
8337
8461
|
TrainingFundingDraftRefSchema,
|
|
@@ -8450,6 +8574,7 @@ export {
|
|
|
8450
8574
|
createSteeringProfileClient,
|
|
8451
8575
|
createTrainingCheckpointRecoveryResourceApproval,
|
|
8452
8576
|
createTrainingClient,
|
|
8577
|
+
createTrainingExperimentLearningClient,
|
|
8453
8578
|
createTrainingFundingClient,
|
|
8454
8579
|
createTrainingHardwareCatalogClient,
|
|
8455
8580
|
createTrainingModelSaveClient,
|
|
@@ -8619,6 +8744,12 @@ export {
|
|
|
8619
8744
|
trainingEvaluationTaskPageHash,
|
|
8620
8745
|
trainingExecutionReceiptHash,
|
|
8621
8746
|
trainingExperimentConfigurationIdentity,
|
|
8747
|
+
trainingExperimentInitialLearning,
|
|
8748
|
+
trainingExperimentLearningInputHash,
|
|
8749
|
+
trainingExperimentLearningRequest,
|
|
8750
|
+
trainingExperimentLearningSettings,
|
|
8751
|
+
trainingExperimentSavedConfiguration,
|
|
8752
|
+
trainingExperimentTrainingInputHash,
|
|
8622
8753
|
trainingInputArtifactUploadHash,
|
|
8623
8754
|
trainingJobSubmissionHash,
|
|
8624
8755
|
trainingModelServingState,
|