openpond-sdk 0.12.16 → 0.12.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VPK3SM45.js → chunk-BJMENXR4.js} +2 -1
- package/dist/{chunk-VPK3SM45.js.map → chunk-BJMENXR4.js.map} +1 -1
- package/dist/{chunk-FBZTDDRC.js → chunk-C5LW5IFH.js} +2 -2
- package/dist/{chunk-WM3U4RPZ.js → chunk-JMXFHO2W.js} +40 -9
- package/dist/chunk-JMXFHO2W.js.map +1 -0
- package/dist/{chunk-HJ2AIAKX.js → chunk-QJCCNBMZ.js} +11 -1
- package/dist/chunk-QJCCNBMZ.js.map +1 -0
- package/dist/{chunk-L6EJX2VQ.js → chunk-VQ34VXAZ.js} +2 -2
- package/dist/{chunk-3DWPLYFJ.js → chunk-ZDOGI6PB.js} +2 -2
- package/dist/index.js +4 -4
- package/dist/learning.js +2 -2
- package/dist/learning.js.map +1 -1
- package/dist/model-starter-catalog.js +1 -1
- package/dist/model-starters.js +1 -1
- package/dist/post-training.js +1 -1
- package/dist/profile-actions.js +2 -2
- package/dist/project-actions.js +2 -2
- package/dist/training-bundle.js +1 -1
- package/dist/training.js +1096 -970
- package/dist/training.js.map +1 -1
- package/dist/types/packages/cloud/src/api/client-context.d.ts +5 -0
- package/dist/types/packages/cloud/src/api/client-context.d.ts.map +1 -0
- package/dist/types/packages/cloud/src/api/core.d.ts.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 +1030 -82
- 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-supervised-training-defaults.d.ts +1 -1
- package/dist/types/packages/sdk/src/model-supervised-training-defaults.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/model-taskset-runs.d.ts +216 -216
- package/dist/types/packages/sdk/src/model-training-defaults.d.ts +1 -1
- package/dist/types/packages/sdk/src/model-training-defaults.d.ts.map +1 -1
- 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 +16 -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 +683 -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 +543 -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/dist/workflows.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-HJ2AIAKX.js.map +0 -1
- package/dist/chunk-WM3U4RPZ.js.map +0 -1
- /package/dist/{chunk-FBZTDDRC.js.map → chunk-C5LW5IFH.js.map} +0 -0
- /package/dist/{chunk-L6EJX2VQ.js.map → chunk-VQ34VXAZ.js.map} +0 -0
- /package/dist/{chunk-3DWPLYFJ.js.map → chunk-ZDOGI6PB.js.map} +0 -0
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,21 @@ var EngramExperimentFormDraftSchema = z33.object({
|
|
|
3397
3400
|
startingModule: SavedEngramExperimentSourceSchema.optional()
|
|
3398
3401
|
}).strict();
|
|
3399
3402
|
|
|
3403
|
+
// src/training-experiment-setup.ts
|
|
3404
|
+
import { LearningRevisionRefSchema } from "@openpond/evals/learning";
|
|
3405
|
+
|
|
3406
|
+
// src/training-experiment-learning-intent.ts
|
|
3407
|
+
import { z as z34 } from "zod";
|
|
3408
|
+
var TrainingExperimentLearningIntentSchema = z34.object({
|
|
3409
|
+
enabled: z34.boolean(),
|
|
3410
|
+
mode: z34.enum(["nightly", "approved_count"]),
|
|
3411
|
+
minimumTasks: z34.string().max(100),
|
|
3412
|
+
localTime: z34.string().max(100),
|
|
3413
|
+
timeZone: z34.string().max(200),
|
|
3414
|
+
maximumSpendUsd: z34.string().max(100),
|
|
3415
|
+
maximumDailySpendUsd: z34.string().max(100)
|
|
3416
|
+
}).strict();
|
|
3417
|
+
|
|
3400
3418
|
// src/steering-experiment-source-verification.ts
|
|
3401
3419
|
function savedSteeringExperimentSource(version) {
|
|
3402
3420
|
return SavedSteeringExperimentSourceSchema.parse({
|
|
@@ -3415,35 +3433,35 @@ async function verifySavedSteeringExperimentSource(raw, resolved, expected = {})
|
|
|
3415
3433
|
}
|
|
3416
3434
|
|
|
3417
3435
|
// src/experiment-starting-model.ts
|
|
3418
|
-
import { z as
|
|
3436
|
+
import { z as z35 } from "zod";
|
|
3419
3437
|
var fields = {
|
|
3420
|
-
label:
|
|
3421
|
-
inferenceModelId:
|
|
3438
|
+
label: z35.string().trim().min(1).max(500),
|
|
3439
|
+
inferenceModelId: z35.string().trim().min(1).max(500).nullable(),
|
|
3422
3440
|
baseModel: ModelProjectBaseModelSchema.nullable()
|
|
3423
3441
|
};
|
|
3424
|
-
var ExperimentStartingModelSchema =
|
|
3425
|
-
|
|
3442
|
+
var ExperimentStartingModelSchema = z35.discriminatedUnion("source", [
|
|
3443
|
+
z35.object({ ...fields, source: z35.literal("inference") }).strict().refine(
|
|
3426
3444
|
(value) => Boolean(value.inferenceModelId),
|
|
3427
3445
|
{ message: "Retain the selected model's original inference identity." }
|
|
3428
3446
|
),
|
|
3429
|
-
|
|
3447
|
+
z35.object({ ...fields, source: z35.literal("managed") }).strict().refine(
|
|
3430
3448
|
(value) => Boolean(value.baseModel),
|
|
3431
3449
|
{ message: "Retain the selected model's original managed identity." }
|
|
3432
3450
|
),
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3451
|
+
z35.object({ ...fields, source: z35.literal("steering"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, steering: SavedSteeringExperimentSourceSchema }).strict(),
|
|
3452
|
+
z35.object({ ...fields, source: z35.literal("engram"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, engram: SavedEngramExperimentSourceSchema }).strict(),
|
|
3453
|
+
z35.object({ ...fields, source: z35.literal("alphaedit"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, alphaedit: SavedAlphaEditExperimentSourceSchema }).strict(),
|
|
3454
|
+
z35.object({ ...fields, source: z35.literal("neuron_training"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, neuronTraining: SavedNeuronTrainingExperimentSourceSchema }).strict(),
|
|
3455
|
+
z35.object({ ...fields, source: z35.literal("decision"), inferenceModelId: z35.null(), baseModel: ModelProjectBaseModelSchema, decision: SavedDecisionExperimentSourceSchema }).strict().superRefine((value, context) => {
|
|
3438
3456
|
if (canonicalJson(value.baseModel) !== canonicalJson(decisionSourcePreference()))
|
|
3439
3457
|
context.addIssue({ code: "custom", path: ["baseModel"], message: "Retain the saved decision Model's exact adapter release and its own tokenizer." });
|
|
3440
3458
|
}),
|
|
3441
|
-
|
|
3459
|
+
z35.object({
|
|
3442
3460
|
...fields,
|
|
3443
|
-
source:
|
|
3444
|
-
inferenceModelId:
|
|
3461
|
+
source: z35.literal("trained"),
|
|
3462
|
+
inferenceModelId: z35.null(),
|
|
3445
3463
|
baseModel: ModelProjectBaseModelSchema,
|
|
3446
|
-
trainedVersion:
|
|
3464
|
+
trainedVersion: z35.lazy(() => TrainingModelVersionSchema)
|
|
3447
3465
|
}).strict().superRefine((value, context) => {
|
|
3448
3466
|
if (canonicalJson(value.baseModel) !== canonicalJson(value.trainedVersion.request.baseModel))
|
|
3449
3467
|
context.addIssue({ code: "custom", path: ["baseModel"], message: "Retain the trained version's exact original base." });
|
|
@@ -3481,12 +3499,13 @@ async function parseAndVerifyExperimentStartingModel(raw, expected = {}) {
|
|
|
3481
3499
|
}
|
|
3482
3500
|
|
|
3483
3501
|
// src/training-experiment-setup.ts
|
|
3484
|
-
var ExperimentOperationTypeSchema =
|
|
3502
|
+
var ExperimentOperationTypeSchema = z36.enum(["evaluate", "sft", "grpo", "neuron_steering", "inspect_activations", "engram_adapter", "decision_model", "alphaedit", "selective_neuron_training"]);
|
|
3485
3503
|
function experimentOperationLabel(type) {
|
|
3486
3504
|
return { evaluate: "Evaluate", sft: "SFT + LoRA", grpo: "RL (GRPO) + LoRA", 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
3505
|
}
|
|
3488
3506
|
var TrainingExperimentSetupRequestSchema = TrainingPreparationRequestSchema.omit({ configuration: true, origin: true }).extend({
|
|
3489
|
-
schemaVersion:
|
|
3507
|
+
schemaVersion: z36.literal("openpond.trainingExperimentSetupRequest.v1"),
|
|
3508
|
+
configuration: TrainingPreparationRequestSchema.shape.configuration.optional(),
|
|
3490
3509
|
baseModel: ModelProjectBaseModelSchema,
|
|
3491
3510
|
settings: ModelProjectTrainingSetupSchema.omit({ baseModel: true })
|
|
3492
3511
|
}).strict().superRefine((value, context) => {
|
|
@@ -3499,10 +3518,10 @@ var TrainingExperimentSetupRequestSchema = TrainingPreparationRequestSchema.omit
|
|
|
3499
3518
|
if (value.settings.method !== value.settings.recipe?.method)
|
|
3500
3519
|
context.addIssue({ code: "custom", path: ["settings", "method"], message: "The method must match its recipe." });
|
|
3501
3520
|
});
|
|
3502
|
-
var TrainingExperimentSetupReceiptSchema =
|
|
3503
|
-
schemaVersion:
|
|
3521
|
+
var TrainingExperimentSetupReceiptSchema = z36.object({
|
|
3522
|
+
schemaVersion: z36.literal("openpond.trainingExperimentSetupReceipt.v1"),
|
|
3504
3523
|
request: TrainingExperimentSetupRequestSchema,
|
|
3505
|
-
requestHash:
|
|
3524
|
+
requestHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3506
3525
|
preparation: TrainingPreparationReceiptSchema
|
|
3507
3526
|
}).strict();
|
|
3508
3527
|
async function trainingExperimentConfigurationIdentity(input, creatorUserId) {
|
|
@@ -3511,10 +3530,10 @@ async function trainingExperimentConfigurationIdentity(input, creatorUserId) {
|
|
|
3511
3530
|
async function parseAndVerifyTrainingExperimentSetupReceipt(raw) {
|
|
3512
3531
|
const result = TrainingExperimentSetupReceiptSchema.parse(raw);
|
|
3513
3532
|
const preparation = await parseAndVerifyTrainingPreparationReceipt(result.preparation);
|
|
3514
|
-
const { schemaVersion: _schema, baseModel: _base, settings: _settings, ...run } = result.request;
|
|
3533
|
+
const { schemaVersion: _schema, baseModel: _base, settings: _settings, configuration: selectedConfiguration, ...run } = result.request;
|
|
3515
3534
|
const { schemaVersion: _preparedSchema, configuration, ...preparedRun } = preparation.plan.request;
|
|
3516
3535
|
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.");
|
|
3536
|
+
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
3537
|
return { ...result, preparation };
|
|
3519
3538
|
}
|
|
3520
3539
|
function createTrainingExperimentSetupClient(request) {
|
|
@@ -3531,42 +3550,49 @@ function createTrainingExperimentSetupClient(request) {
|
|
|
3531
3550
|
}
|
|
3532
3551
|
};
|
|
3533
3552
|
}
|
|
3534
|
-
var TrainingExperimentInputsPageSchema =
|
|
3535
|
-
schemaVersion:
|
|
3536
|
-
teamId:
|
|
3537
|
-
actorId:
|
|
3538
|
-
projectId:
|
|
3539
|
-
models:
|
|
3540
|
-
methods:
|
|
3553
|
+
var TrainingExperimentInputsPageSchema = z36.object({
|
|
3554
|
+
schemaVersion: z36.literal("openpond.trainingExperimentInputsPage.v1"),
|
|
3555
|
+
teamId: z36.string().min(1).max(500),
|
|
3556
|
+
actorId: z36.string().min(1).max(500),
|
|
3557
|
+
projectId: z36.string().min(1).max(500).nullable(),
|
|
3558
|
+
models: z36.array(ModelProjectBaseModelCandidateSchema).max(1e3),
|
|
3559
|
+
methods: z36.array(z36.string().min(1).max(200)).max(100),
|
|
3541
3560
|
billingModes: TrainingBillingModesSchema.optional(),
|
|
3542
|
-
batches:
|
|
3561
|
+
batches: z36.array(z36.object({
|
|
3543
3562
|
reference: ModelProjectVersionedRefSchema,
|
|
3544
3563
|
rewardBinding: ModelProjectVersionedRefSchema,
|
|
3545
|
-
purpose:
|
|
3546
|
-
exampleCount:
|
|
3547
|
-
sealedAt:
|
|
3564
|
+
purpose: z36.enum(["supervised_training", "reward_training", "evaluation"]),
|
|
3565
|
+
exampleCount: z36.number().int().positive(),
|
|
3566
|
+
sealedAt: z36.iso.datetime()
|
|
3548
3567
|
}).strict()).max(100),
|
|
3549
|
-
nextCursor:
|
|
3568
|
+
nextCursor: z36.string().min(1).max(500).nullable()
|
|
3550
3569
|
}).strict();
|
|
3551
|
-
var TrainingExperimentFormDraftSchema =
|
|
3570
|
+
var TrainingExperimentFormDraftSchema = z36.object({
|
|
3552
3571
|
baseModel: ModelProjectBaseModelSchema.nullable(),
|
|
3553
3572
|
recipe: ModelProjectRecipeDocumentSchema,
|
|
3554
3573
|
batch: ModelProjectVersionedRefSchema.nullable(),
|
|
3555
3574
|
evaluation: ModelProjectVersionedRefSchema.nullable(),
|
|
3556
|
-
validationSplit:
|
|
3557
|
-
name:
|
|
3558
|
-
budget:
|
|
3559
|
-
customerCapUsd:
|
|
3560
|
-
billingMode:
|
|
3575
|
+
validationSplit: z36.enum(["validation", "frozen_eval"]),
|
|
3576
|
+
name: z36.string().max(500),
|
|
3577
|
+
budget: z36.string().max(100),
|
|
3578
|
+
customerCapUsd: z36.string().max(100).optional(),
|
|
3579
|
+
billingMode: z36.enum(["prepaid_only", "actual_usage"]).optional(),
|
|
3561
3580
|
gpuSelection: TrainingGpuSelectionSchema.optional(),
|
|
3562
3581
|
parent: TrainingPreparationRequestSchema.shape.parent,
|
|
3563
|
-
startingModelLabel:
|
|
3582
|
+
startingModelLabel: z36.string().trim().min(1).max(500).optional(),
|
|
3583
|
+
learningIntent: TrainingExperimentLearningIntentSchema.optional(),
|
|
3584
|
+
learningConfiguration: z36.object({
|
|
3585
|
+
inputHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3586
|
+
trainingInputHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
3587
|
+
configuration: HostedModelProjectSummarySchema,
|
|
3588
|
+
policy: LearningRevisionRefSchema
|
|
3589
|
+
}).strict().optional()
|
|
3564
3590
|
}).strict();
|
|
3565
|
-
var ExperimentDraftSchema =
|
|
3566
|
-
schemaVersion:
|
|
3567
|
-
id:
|
|
3591
|
+
var ExperimentDraftSchema = z36.object({
|
|
3592
|
+
schemaVersion: z36.literal("openpond.experimentDraft.v1"),
|
|
3593
|
+
id: z36.string().trim().min(1).max(240),
|
|
3568
3594
|
operationType: ExperimentOperationTypeSchema,
|
|
3569
|
-
name:
|
|
3595
|
+
name: z36.string().trim().min(1).max(500),
|
|
3570
3596
|
startingModel: ExperimentStartingModelSchema.optional(),
|
|
3571
3597
|
evaluationForm: EvaluationExperimentDraftSchema.optional(),
|
|
3572
3598
|
hostedEvaluationForm: HostedEvaluationExperimentFormDraftSchema.optional(),
|
|
@@ -3576,7 +3602,7 @@ var ExperimentDraftSchema = z35.object({
|
|
|
3576
3602
|
decisionForm: DecisionExperimentFormDraftSchema.optional(),
|
|
3577
3603
|
alphaEditForm: AlphaEditExperimentFormDraftSchema.optional(),
|
|
3578
3604
|
neuronTrainingForm: NeuronTrainingExperimentFormDraftSchema.optional(),
|
|
3579
|
-
training:
|
|
3605
|
+
training: z36.object({
|
|
3580
3606
|
baseModel: TrainingExperimentSetupRequestSchema.shape.baseModel.optional(),
|
|
3581
3607
|
settings: TrainingExperimentSetupRequestSchema.shape.settings.optional(),
|
|
3582
3608
|
batch: TrainingExperimentSetupRequestSchema.shape.batch.optional(),
|
|
@@ -3664,75 +3690,75 @@ async function parseAndVerifyExperimentDraft(raw, expected = {}) {
|
|
|
3664
3690
|
if (draft.startingModel) await parseAndVerifyExperimentStartingModel(draft.startingModel, expected);
|
|
3665
3691
|
return draft;
|
|
3666
3692
|
}
|
|
3667
|
-
var ExperimentDraftUpdateSchema =
|
|
3668
|
-
schemaVersion:
|
|
3669
|
-
operationId:
|
|
3670
|
-
expectedRevision:
|
|
3693
|
+
var ExperimentDraftUpdateSchema = z36.object({
|
|
3694
|
+
schemaVersion: z36.literal("openpond.experimentDraftUpdate.v1"),
|
|
3695
|
+
operationId: z36.string().trim().min(1).max(240),
|
|
3696
|
+
expectedRevision: z36.number().int().positive(),
|
|
3671
3697
|
draft: ExperimentDraftSchema
|
|
3672
3698
|
}).strict();
|
|
3673
3699
|
|
|
3674
3700
|
// src/experiment-draft-storage.ts
|
|
3675
|
-
var Id21 =
|
|
3676
|
-
var StoredExperimentDraftReferenceSchema =
|
|
3701
|
+
var Id21 = z37.string().trim().min(1).max(240);
|
|
3702
|
+
var StoredExperimentDraftReferenceSchema = z37.object({
|
|
3677
3703
|
id: Id21,
|
|
3678
3704
|
teamId: Id21,
|
|
3679
|
-
apiOrigin:
|
|
3705
|
+
apiOrigin: z37.url().max(2e3)
|
|
3680
3706
|
}).strict();
|
|
3681
|
-
var ExperimentDraftRecordSchema =
|
|
3682
|
-
schemaVersion:
|
|
3707
|
+
var ExperimentDraftRecordSchema = z37.object({
|
|
3708
|
+
schemaVersion: z37.literal("openpond.experimentDraftRecord.v1"),
|
|
3683
3709
|
id: Id21,
|
|
3684
3710
|
teamId: Id21,
|
|
3685
3711
|
ownerUserId: Id21,
|
|
3686
3712
|
projectId: Id21.nullable(),
|
|
3687
|
-
revision:
|
|
3688
|
-
status:
|
|
3713
|
+
revision: z37.number().int().positive(),
|
|
3714
|
+
status: z37.enum(["draft", "archived"]),
|
|
3689
3715
|
draft: ExperimentDraftSchema,
|
|
3690
|
-
createdAt:
|
|
3691
|
-
updatedAt:
|
|
3692
|
-
contentHash:
|
|
3716
|
+
createdAt: z37.iso.datetime(),
|
|
3717
|
+
updatedAt: z37.iso.datetime(),
|
|
3718
|
+
contentHash: z37.string().regex(/^[a-f0-9]{64}$/)
|
|
3693
3719
|
}).strict().superRefine((record, context) => {
|
|
3694
3720
|
if (record.id !== record.draft.id)
|
|
3695
3721
|
context.addIssue({ code: "custom", path: ["id"], message: "The stored draft identity does not match its document." });
|
|
3696
3722
|
});
|
|
3697
|
-
var ExperimentDraftSaveSchema =
|
|
3698
|
-
schemaVersion:
|
|
3723
|
+
var ExperimentDraftSaveSchema = z37.object({
|
|
3724
|
+
schemaVersion: z37.literal("openpond.experimentDraftSave.v1"),
|
|
3699
3725
|
teamId: Id21,
|
|
3700
3726
|
operationId: Id21,
|
|
3701
|
-
expectedRevision:
|
|
3727
|
+
expectedRevision: z37.number().int().nonnegative(),
|
|
3702
3728
|
projectId: Id21.nullable().default(null),
|
|
3703
3729
|
draft: ExperimentDraftSchema
|
|
3704
3730
|
}).strict();
|
|
3705
|
-
var ExperimentDraftArchiveSchema =
|
|
3706
|
-
schemaVersion:
|
|
3731
|
+
var ExperimentDraftArchiveSchema = z37.object({
|
|
3732
|
+
schemaVersion: z37.literal("openpond.experimentDraftArchive.v1"),
|
|
3707
3733
|
teamId: Id21,
|
|
3708
3734
|
operationId: Id21,
|
|
3709
|
-
expectedRevision:
|
|
3735
|
+
expectedRevision: z37.number().int().positive()
|
|
3710
3736
|
}).strict();
|
|
3711
|
-
var ExperimentDraftReceiptSchema =
|
|
3712
|
-
schemaVersion:
|
|
3737
|
+
var ExperimentDraftReceiptSchema = z37.object({
|
|
3738
|
+
schemaVersion: z37.literal("openpond.experimentDraftReceipt.v1"),
|
|
3713
3739
|
operationId: Id21,
|
|
3714
|
-
requestHash:
|
|
3740
|
+
requestHash: z37.string().regex(/^[a-f0-9]{64}$/),
|
|
3715
3741
|
record: ExperimentDraftRecordSchema
|
|
3716
3742
|
}).strict();
|
|
3717
|
-
var ExperimentDraftListQuerySchema =
|
|
3743
|
+
var ExperimentDraftListQuerySchema = z37.object({
|
|
3718
3744
|
projectId: Id21.optional(),
|
|
3719
|
-
search:
|
|
3720
|
-
archived:
|
|
3721
|
-
cursor:
|
|
3722
|
-
limit:
|
|
3745
|
+
search: z37.string().trim().max(1e3).optional(),
|
|
3746
|
+
archived: z37.boolean().default(false),
|
|
3747
|
+
cursor: z37.string().min(1).max(2e3).optional(),
|
|
3748
|
+
limit: z37.number().int().min(1).max(100).default(30)
|
|
3723
3749
|
}).strict();
|
|
3724
|
-
var ExperimentDraftPageSchema =
|
|
3725
|
-
schemaVersion:
|
|
3750
|
+
var ExperimentDraftPageSchema = z37.object({
|
|
3751
|
+
schemaVersion: z37.literal("openpond.experimentDraftPage.v1"),
|
|
3726
3752
|
teamId: Id21,
|
|
3727
3753
|
ownerUserId: Id21,
|
|
3728
3754
|
projectId: Id21.nullable(),
|
|
3729
|
-
items:
|
|
3730
|
-
nextCursor:
|
|
3755
|
+
items: z37.array(ExperimentDraftRecordSchema).max(100),
|
|
3756
|
+
nextCursor: z37.string().min(1).max(2e3).nullable()
|
|
3731
3757
|
}).strict();
|
|
3732
3758
|
async function parseAndVerifyExperimentDraftRecord(raw) {
|
|
3733
3759
|
const record = ExperimentDraftRecordSchema.parse(raw);
|
|
3734
|
-
const { contentHash, ...content } = record;
|
|
3735
|
-
if (
|
|
3760
|
+
const { contentHash: contentHash2, ...content } = record;
|
|
3761
|
+
if (contentHash2 !== await canonicalSha256(content))
|
|
3736
3762
|
throw new OpenPondProtocolError("experiment_draft_hash_mismatch", "The saved draft differs from its retained document.");
|
|
3737
3763
|
await parseAndVerifyExperimentDraft(record.draft, { teamId: record.teamId });
|
|
3738
3764
|
return record;
|
|
@@ -3791,21 +3817,21 @@ function createExperimentDraftClient(request) {
|
|
|
3791
3817
|
}
|
|
3792
3818
|
|
|
3793
3819
|
// src/managed-modification-executions.ts
|
|
3794
|
-
import { z as
|
|
3820
|
+
import { z as z39 } from "zod";
|
|
3795
3821
|
|
|
3796
3822
|
// src/managed-modification-compilation.ts
|
|
3797
|
-
import { z as
|
|
3798
|
-
var Id22 =
|
|
3799
|
-
var Hash27 =
|
|
3800
|
-
var ManagedModificationCompileSchema =
|
|
3823
|
+
import { z as z38 } from "zod";
|
|
3824
|
+
var Id22 = z38.string().trim().min(1).max(240);
|
|
3825
|
+
var Hash27 = z38.string().regex(/^[a-f0-9]{64}$/);
|
|
3826
|
+
var ManagedModificationCompileSchema = z38.object({
|
|
3801
3827
|
teamId: Id22,
|
|
3802
3828
|
projectId: Id22.nullable(),
|
|
3803
3829
|
method: ModelModificationMethodSchema,
|
|
3804
3830
|
query: ModelModificationCapabilitiesQuerySchema,
|
|
3805
3831
|
form: ActivationExperimentFormDraftSchema
|
|
3806
3832
|
}).strict();
|
|
3807
|
-
var ManagedModificationCompilationContentSchema =
|
|
3808
|
-
schemaVersion:
|
|
3833
|
+
var ManagedModificationCompilationContentSchema = z38.object({
|
|
3834
|
+
schemaVersion: z38.literal("openpond.managedModificationCompilation.v1"),
|
|
3809
3835
|
teamId: Id22,
|
|
3810
3836
|
actorId: Id22,
|
|
3811
3837
|
projectId: Id22.nullable(),
|
|
@@ -3837,37 +3863,37 @@ function parseManagedModificationCompile(raw) {
|
|
|
3837
3863
|
}
|
|
3838
3864
|
async function parseAndVerifyManagedModificationCompilation(raw, input) {
|
|
3839
3865
|
const command = parseManagedModificationCompile(input), value = ManagedModificationCompilationSchema.parse(raw);
|
|
3840
|
-
const { contentHash, ...content } = value, request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3866
|
+
const { contentHash: contentHash2, ...content } = value, request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3841
3867
|
if (canonicalJson(command.form.startingProfile ?? null) !== canonicalJson(request.startingProfile ? activationStartingProfileSource(request.startingProfile) : null))
|
|
3842
3868
|
throw new OpenPondProtocolError("managed_modification_compilation_mismatch", "The compilation dropped or changed the saved steering source.");
|
|
3843
3869
|
const profiles = request.variants.filter((row) => row.profile !== null).length;
|
|
3844
|
-
if (
|
|
3870
|
+
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
3871
|
throw new OpenPondProtocolError("managed_modification_compilation_mismatch", "The compilation differs from the exact requested form, model or bounds.");
|
|
3846
3872
|
return value;
|
|
3847
3873
|
}
|
|
3848
3874
|
|
|
3849
3875
|
// src/managed-modification-executions.ts
|
|
3850
|
-
var Id23 =
|
|
3851
|
-
var Hash28 =
|
|
3852
|
-
var ManagedModificationExecutionContentSchema =
|
|
3853
|
-
schemaVersion:
|
|
3876
|
+
var Id23 = z39.string().trim().min(1).max(240);
|
|
3877
|
+
var Hash28 = z39.string().regex(/^[a-f0-9]{64}$/);
|
|
3878
|
+
var ManagedModificationExecutionContentSchema = z39.object({
|
|
3879
|
+
schemaVersion: z39.literal("openpond.managedModificationExecution.v1"),
|
|
3854
3880
|
id: Id23,
|
|
3855
3881
|
teamId: Id23,
|
|
3856
3882
|
ownerUserId: Id23,
|
|
3857
3883
|
projectId: Id23.nullable(),
|
|
3858
|
-
name:
|
|
3884
|
+
name: z39.string().trim().min(1).max(500),
|
|
3859
3885
|
method: ModelModificationMethodSchema,
|
|
3860
|
-
phase:
|
|
3861
|
-
revision:
|
|
3886
|
+
phase: z39.enum(["prepared", "queued", "dispatching", "stopping", "cancelled", "completed", "failed"]),
|
|
3887
|
+
revision: z39.number().int().positive(),
|
|
3862
3888
|
sourceContentHash: Hash28,
|
|
3863
|
-
plan:
|
|
3889
|
+
plan: z39.object({
|
|
3864
3890
|
contentHash: Hash28,
|
|
3865
3891
|
inputHash: Hash28,
|
|
3866
3892
|
runtimeHash: Hash28,
|
|
3867
|
-
maximumSpendUsd:
|
|
3893
|
+
maximumSpendUsd: z39.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48).nullable(),
|
|
3868
3894
|
computePrice: ManagedModificationPriceSchema.optional(),
|
|
3869
|
-
createdAt:
|
|
3870
|
-
expiresAt:
|
|
3895
|
+
createdAt: z39.iso.datetime(),
|
|
3896
|
+
expiresAt: z39.iso.datetime()
|
|
3871
3897
|
}).strict().superRefine((plan, ctx) => {
|
|
3872
3898
|
try {
|
|
3873
3899
|
assertManagedModificationPricing(plan);
|
|
@@ -3878,58 +3904,58 @@ var ManagedModificationExecutionContentSchema = z38.object({
|
|
|
3878
3904
|
request: ActivationReferenceRequestSchema,
|
|
3879
3905
|
sourceForm: ActivationExperimentFormDraftSchema.optional(),
|
|
3880
3906
|
result: ActivationReferenceResultSchema.nullable(),
|
|
3881
|
-
resultRecordedAt:
|
|
3882
|
-
updatedAt:
|
|
3907
|
+
resultRecordedAt: z39.iso.datetime().nullable(),
|
|
3908
|
+
updatedAt: z39.iso.datetime()
|
|
3883
3909
|
}).strict();
|
|
3884
3910
|
var ManagedModificationExecutionSchema = ManagedModificationExecutionContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3885
|
-
var Spend =
|
|
3886
|
-
var ManagedModificationPrepareSchema =
|
|
3911
|
+
var Spend = z39.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
3912
|
+
var ManagedModificationPrepareSchema = z39.object({
|
|
3887
3913
|
teamId: Id23,
|
|
3888
3914
|
operationId: Id23,
|
|
3889
3915
|
projectId: Id23.nullable(),
|
|
3890
|
-
name:
|
|
3916
|
+
name: z39.string().trim().min(1).max(500),
|
|
3891
3917
|
method: ModelModificationMethodSchema,
|
|
3892
3918
|
query: ModelModificationCapabilitiesQuerySchema,
|
|
3893
3919
|
request: ActivationReferenceRequestSchema,
|
|
3894
3920
|
maximumSpendUsd: Spend.nullish(),
|
|
3895
3921
|
sourceForm: ActivationExperimentFormDraftSchema.optional()
|
|
3896
3922
|
}).strict();
|
|
3897
|
-
var control = { teamId: Id23, id: Id23, operationId: Id23, expectedRevision:
|
|
3898
|
-
var ManagedModificationStartSchema =
|
|
3899
|
-
var ManagedModificationCancelSchema =
|
|
3923
|
+
var control = { teamId: Id23, id: Id23, operationId: Id23, expectedRevision: z39.number().int().positive(), planHash: Hash28 };
|
|
3924
|
+
var ManagedModificationStartSchema = z39.object({ ...control, action: z39.literal("start"), approvedMaximumSpendUsd: Spend.nullable(), approvedPriceHash: Hash28.optional() }).strict();
|
|
3925
|
+
var ManagedModificationCancelSchema = z39.object({ ...control, action: z39.literal("cancel") }).strict();
|
|
3900
3926
|
var ManagedModificationExecutionMetadataSchema = ManagedModificationExecutionContentSchema.omit({ schemaVersion: true, request: true, sourceForm: true, result: true, resultRecordedAt: true });
|
|
3901
|
-
var ManagedModificationExecutionReceiptContentSchema =
|
|
3902
|
-
schemaVersion:
|
|
3927
|
+
var ManagedModificationExecutionReceiptContentSchema = z39.object({
|
|
3928
|
+
schemaVersion: z39.literal("openpond.managedModificationExecutionReceipt.v1"),
|
|
3903
3929
|
operationId: Id23,
|
|
3904
3930
|
requestHash: Hash28,
|
|
3905
3931
|
execution: ManagedModificationExecutionMetadataSchema
|
|
3906
3932
|
}).strict();
|
|
3907
3933
|
var ManagedModificationExecutionReceiptSchema = ManagedModificationExecutionReceiptContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3908
|
-
var ManagedModificationExecutionListQuerySchema =
|
|
3934
|
+
var ManagedModificationExecutionListQuerySchema = z39.object({
|
|
3909
3935
|
id: Id23.optional(),
|
|
3910
3936
|
projectId: Id23.optional(),
|
|
3911
3937
|
method: ModelModificationMethodSchema.optional(),
|
|
3912
3938
|
phase: ManagedModificationExecutionContentSchema.shape.phase.optional(),
|
|
3913
|
-
limit:
|
|
3914
|
-
cursor:
|
|
3939
|
+
limit: z39.number().int().min(1).max(100).default(25),
|
|
3940
|
+
cursor: z39.string().min(1).max(2048).optional()
|
|
3915
3941
|
}).strict();
|
|
3916
3942
|
var ManagedModificationExecutionSummarySchema = ManagedModificationExecutionMetadataSchema.extend({
|
|
3917
3943
|
model: ActivationReferenceRequestSchema.shape.model
|
|
3918
3944
|
}).strict();
|
|
3919
|
-
var ManagedModificationExecutionPageContentSchema =
|
|
3920
|
-
schemaVersion:
|
|
3945
|
+
var ManagedModificationExecutionPageContentSchema = z39.object({
|
|
3946
|
+
schemaVersion: z39.literal("openpond.managedModificationExecutionPage.v1"),
|
|
3921
3947
|
teamId: Id23,
|
|
3922
3948
|
ownerUserId: Id23,
|
|
3923
3949
|
query: ManagedModificationExecutionListQuerySchema,
|
|
3924
|
-
items:
|
|
3925
|
-
nextCursor:
|
|
3950
|
+
items: z39.array(ManagedModificationExecutionSummarySchema).max(100),
|
|
3951
|
+
nextCursor: z39.string().min(1).max(2048).nullable()
|
|
3926
3952
|
}).strict();
|
|
3927
3953
|
var ManagedModificationExecutionPageSchema = ManagedModificationExecutionPageContentSchema.extend({ contentHash: Hash28 }).strict();
|
|
3928
3954
|
async function parseAndVerifyManagedModificationExecutionPage(raw, expected) {
|
|
3929
|
-
const page = ManagedModificationExecutionPageSchema.parse(raw), { contentHash, ...content } = page;
|
|
3955
|
+
const page = ManagedModificationExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = page;
|
|
3930
3956
|
const query = ManagedModificationExecutionListQuerySchema.parse(expected.query ?? {});
|
|
3931
3957
|
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) ||
|
|
3958
|
+
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
3959
|
for (const [index, item] of page.items.entries()) {
|
|
3934
3960
|
const previous = page.items[index - 1];
|
|
3935
3961
|
assertManagedModificationPricing(item.plan);
|
|
@@ -3966,16 +3992,16 @@ async function parseAndVerifyManagedModificationPrepare(raw) {
|
|
|
3966
3992
|
return value;
|
|
3967
3993
|
}
|
|
3968
3994
|
function parseManagedModificationControl(raw) {
|
|
3969
|
-
const value =
|
|
3995
|
+
const value = z39.discriminatedUnion("action", [ManagedModificationStartSchema, ManagedModificationCancelSchema]).parse(raw);
|
|
3970
3996
|
if (value.action === "start") value.approvedMaximumSpendUsd = canonicalComputeSpendCap(value.approvedMaximumSpendUsd);
|
|
3971
3997
|
return value;
|
|
3972
3998
|
}
|
|
3973
3999
|
async function parseAndVerifyManagedModificationExecutionReceipt(raw, input) {
|
|
3974
|
-
const value = ManagedModificationExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4000
|
+
const value = ManagedModificationExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
3975
4001
|
const command = "action" in input ? parseManagedModificationControl(input) : await parseAndVerifyManagedModificationPrepare(input);
|
|
3976
4002
|
const execution = value.execution, prepare = !("action" in command);
|
|
3977
4003
|
const expectedHash = await canonicalSha256(prepare ? { action: "prepare", command } : command);
|
|
3978
|
-
if (
|
|
4004
|
+
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
4005
|
throw new OpenPondProtocolError("managed_modification_receipt_mismatch", "The receipt differs from the original operation and reviewed execution.");
|
|
3980
4006
|
if (prepare) {
|
|
3981
4007
|
const request = command;
|
|
@@ -3991,12 +4017,12 @@ async function parseAndVerifyManagedModificationExecutionReceipt(raw, input) {
|
|
|
3991
4017
|
}
|
|
3992
4018
|
async function parseAndVerifyManagedModificationExecution(raw, expected) {
|
|
3993
4019
|
const value = ManagedModificationExecutionSchema.parse(raw);
|
|
3994
|
-
const { contentHash, ...content } = value;
|
|
4020
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
3995
4021
|
const request = await parseAndVerifyActivationReferenceRequest(value.request);
|
|
3996
4022
|
if (value.sourceForm) verifySourceForm(value.sourceForm, request, value.plan.maximumSpendUsd);
|
|
3997
4023
|
if (request.startingProfile && value.method !== "neuron_steering") throw new OpenPondProtocolError("managed_modification_saved_source_unsupported", "Saved steering sources currently require neuron steering.");
|
|
3998
4024
|
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 ||
|
|
4025
|
+
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
4026
|
throw new OpenPondProtocolError("managed_modification_execution_mismatch", "The execution differs from its retained identity, request or capture.");
|
|
4001
4027
|
if (value.result) await parseAndVerifyActivationReferenceResult(value.result, request);
|
|
4002
4028
|
return value;
|
|
@@ -4053,55 +4079,55 @@ function createManagedModificationExecutionClient(request) {
|
|
|
4053
4079
|
}
|
|
4054
4080
|
|
|
4055
4081
|
// src/managed-engram-executions.ts
|
|
4056
|
-
import { z as
|
|
4057
|
-
var Id24 =
|
|
4058
|
-
var Hash29 =
|
|
4059
|
-
var Money2 =
|
|
4060
|
-
var Method =
|
|
4082
|
+
import { z as z40 } from "zod";
|
|
4083
|
+
var Id24 = z40.string().trim().min(1).max(240);
|
|
4084
|
+
var Hash29 = z40.string().regex(/^[a-f0-9]{64}$/);
|
|
4085
|
+
var Money2 = z40.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4086
|
+
var Method = z40.literal("engram_adapter");
|
|
4061
4087
|
var Query = ModelModificationCapabilitiesQuerySchema;
|
|
4062
|
-
var EngramExecutionCapabilityContentSchema =
|
|
4063
|
-
schemaVersion:
|
|
4088
|
+
var EngramExecutionCapabilityContentSchema = z40.object({
|
|
4089
|
+
schemaVersion: z40.literal("openpond.engramExecutionCapability.v1"),
|
|
4064
4090
|
teamId: Id24,
|
|
4065
4091
|
actorId: Id24,
|
|
4066
4092
|
query: Query,
|
|
4067
4093
|
requestHash: Hash29,
|
|
4068
|
-
checkedAt:
|
|
4069
|
-
expiresAt:
|
|
4094
|
+
checkedAt: z40.iso.datetime(),
|
|
4095
|
+
expiresAt: z40.iso.datetime(),
|
|
4070
4096
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4071
|
-
execution:
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
state:
|
|
4097
|
+
execution: z40.discriminatedUnion("state", [
|
|
4098
|
+
z40.object({ state: z40.literal("unavailable"), code: z40.enum(["model_not_supported", "runtime_not_qualified"]), reason: z40.string().min(1).max(1e3) }).strict(),
|
|
4099
|
+
z40.object({
|
|
4100
|
+
state: z40.literal("ready"),
|
|
4075
4101
|
model: NeuronSteeringModelSchema,
|
|
4076
4102
|
config: EngramAdapterConfigSchema,
|
|
4077
|
-
runtime:
|
|
4103
|
+
runtime: z40.object({
|
|
4078
4104
|
id: Id24,
|
|
4079
4105
|
releaseHash: Hash29,
|
|
4080
|
-
imageDigest:
|
|
4081
|
-
requestSchema:
|
|
4082
|
-
evidence:
|
|
4106
|
+
imageDigest: z40.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4107
|
+
requestSchema: z40.literal("openpond.engramTrainingRequest.v1"),
|
|
4108
|
+
evidence: z40.object({ id: Id24, contentHash: Hash29 }).strict()
|
|
4083
4109
|
}).strict(),
|
|
4084
|
-
limits:
|
|
4085
|
-
maximumExamples:
|
|
4086
|
-
maximumDataBytes:
|
|
4087
|
-
maximumSteps:
|
|
4088
|
-
maximumSequenceLength:
|
|
4089
|
-
maximumDurationSeconds:
|
|
4090
|
-
maximumCheckpointBytes:
|
|
4110
|
+
limits: z40.object({
|
|
4111
|
+
maximumExamples: z40.number().int().min(1).max(1e3),
|
|
4112
|
+
maximumDataBytes: z40.number().int().positive().max(8388608),
|
|
4113
|
+
maximumSteps: z40.number().int().min(1).max(128),
|
|
4114
|
+
maximumSequenceLength: z40.number().int().min(2).max(8192),
|
|
4115
|
+
maximumDurationSeconds: z40.number().finite().min(1).max(21600),
|
|
4116
|
+
maximumCheckpointBytes: z40.number().int().positive().max(2147483648)
|
|
4091
4117
|
}).strict()
|
|
4092
4118
|
}).strict()
|
|
4093
4119
|
])
|
|
4094
4120
|
}).strict();
|
|
4095
4121
|
var EngramExecutionCapabilitySchema = EngramExecutionCapabilityContentSchema.extend({ contentHash: Hash29 });
|
|
4096
|
-
var ManagedEngramCompileSchema =
|
|
4122
|
+
var ManagedEngramCompileSchema = z40.object({
|
|
4097
4123
|
teamId: Id24,
|
|
4098
4124
|
projectId: Id24.nullable(),
|
|
4099
4125
|
method: Method,
|
|
4100
4126
|
query: Query,
|
|
4101
4127
|
form: EngramExperimentFormDraftSchema
|
|
4102
4128
|
}).strict();
|
|
4103
|
-
var ManagedEngramCompilationContentSchema =
|
|
4104
|
-
schemaVersion:
|
|
4129
|
+
var ManagedEngramCompilationContentSchema = z40.object({
|
|
4130
|
+
schemaVersion: z40.literal("openpond.managedEngramCompilation.v1"),
|
|
4105
4131
|
teamId: Id24,
|
|
4106
4132
|
actorId: Id24,
|
|
4107
4133
|
projectId: Id24.nullable(),
|
|
@@ -4112,11 +4138,11 @@ var ManagedEngramCompilationContentSchema = z39.object({
|
|
|
4112
4138
|
request: EngramTrainingRequestSchema
|
|
4113
4139
|
}).strict();
|
|
4114
4140
|
var ManagedEngramCompilationSchema = ManagedEngramCompilationContentSchema.extend({ contentHash: Hash29 });
|
|
4115
|
-
var ManagedEngramPrepareSchema =
|
|
4141
|
+
var ManagedEngramPrepareSchema = z40.object({
|
|
4116
4142
|
teamId: Id24,
|
|
4117
4143
|
operationId: Id24,
|
|
4118
4144
|
projectId: Id24.nullable(),
|
|
4119
|
-
name:
|
|
4145
|
+
name: z40.string().trim().min(1).max(500),
|
|
4120
4146
|
method: Method,
|
|
4121
4147
|
query: Query,
|
|
4122
4148
|
request: EngramTrainingRequestSchema,
|
|
@@ -4127,36 +4153,36 @@ var ManagedEngramStartSchema = ManagedModificationStartSchema;
|
|
|
4127
4153
|
var ManagedEngramCancelSchema = ManagedModificationCancelSchema;
|
|
4128
4154
|
var ManagedEngramExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method }).strict();
|
|
4129
4155
|
var ManagedEngramExecutionContentSchema = ManagedEngramExecutionMetadataSchema.extend({
|
|
4130
|
-
schemaVersion:
|
|
4156
|
+
schemaVersion: z40.literal("openpond.managedEngramExecution.v1"),
|
|
4131
4157
|
request: EngramTrainingRequestSchema,
|
|
4132
4158
|
sourceForm: EngramExperimentFormDraftSchema.optional(),
|
|
4133
4159
|
result: EngramTrainingResultSchema.nullable(),
|
|
4134
|
-
resultRecordedAt:
|
|
4160
|
+
resultRecordedAt: z40.iso.datetime().nullable()
|
|
4135
4161
|
}).strict();
|
|
4136
4162
|
var ManagedEngramExecutionSchema = ManagedEngramExecutionContentSchema.extend({ contentHash: Hash29 });
|
|
4137
|
-
var ManagedEngramExecutionReceiptContentSchema =
|
|
4138
|
-
schemaVersion:
|
|
4163
|
+
var ManagedEngramExecutionReceiptContentSchema = z40.object({
|
|
4164
|
+
schemaVersion: z40.literal("openpond.managedEngramExecutionReceipt.v1"),
|
|
4139
4165
|
operationId: Id24,
|
|
4140
4166
|
requestHash: Hash29,
|
|
4141
4167
|
execution: ManagedEngramExecutionMetadataSchema
|
|
4142
4168
|
}).strict();
|
|
4143
4169
|
var ManagedEngramExecutionReceiptSchema = ManagedEngramExecutionReceiptContentSchema.extend({ contentHash: Hash29 });
|
|
4144
|
-
var ManagedEngramExecutionListQuerySchema =
|
|
4170
|
+
var ManagedEngramExecutionListQuerySchema = z40.object({
|
|
4145
4171
|
method: Method.default("engram_adapter"),
|
|
4146
4172
|
id: Id24.optional(),
|
|
4147
4173
|
projectId: Id24.optional(),
|
|
4148
4174
|
phase: ManagedEngramExecutionMetadataSchema.shape.phase.optional(),
|
|
4149
|
-
limit:
|
|
4150
|
-
cursor:
|
|
4175
|
+
limit: z40.number().int().min(1).max(100).default(25),
|
|
4176
|
+
cursor: z40.string().min(1).max(2048).optional()
|
|
4151
4177
|
}).strict();
|
|
4152
4178
|
var ManagedEngramExecutionSummarySchema = ManagedEngramExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4153
|
-
var ManagedEngramExecutionPageContentSchema =
|
|
4154
|
-
schemaVersion:
|
|
4179
|
+
var ManagedEngramExecutionPageContentSchema = z40.object({
|
|
4180
|
+
schemaVersion: z40.literal("openpond.managedEngramExecutionPage.v1"),
|
|
4155
4181
|
teamId: Id24,
|
|
4156
4182
|
ownerUserId: Id24,
|
|
4157
4183
|
query: ManagedEngramExecutionListQuerySchema,
|
|
4158
|
-
items:
|
|
4159
|
-
nextCursor:
|
|
4184
|
+
items: z40.array(ManagedEngramExecutionSummarySchema).max(100),
|
|
4185
|
+
nextCursor: z40.string().min(1).max(2048).nullable()
|
|
4160
4186
|
}).strict();
|
|
4161
4187
|
var ManagedEngramExecutionPageSchema = ManagedEngramExecutionPageContentSchema.extend({ contentHash: Hash29 });
|
|
4162
4188
|
function parseEngramFormTraining(raw) {
|
|
@@ -4189,26 +4215,26 @@ function checkFormQuery(form, query) {
|
|
|
4189
4215
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail3();
|
|
4190
4216
|
}
|
|
4191
4217
|
async function parseAndVerifyEngramExecutionCapability(raw, queryInput, actorId) {
|
|
4192
|
-
const query = Query.parse(queryInput), value = EngramExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4218
|
+
const query = Query.parse(queryInput), value = EngramExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4193
4219
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4194
4220
|
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) ||
|
|
4221
|
+
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
4222
|
if (value.execution.state === "ready") checkSource(query, { model: value.execution.model });
|
|
4197
4223
|
return value;
|
|
4198
4224
|
}
|
|
4199
4225
|
async function parseAndVerifyManagedEngramCompilation(raw, input) {
|
|
4200
|
-
const command = ManagedEngramCompileSchema.parse(input), value = ManagedEngramCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4226
|
+
const command = ManagedEngramCompileSchema.parse(input), value = ManagedEngramCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4201
4227
|
const request = await parseAndVerifyEngramTrainingRequest(value.request);
|
|
4202
4228
|
checkSource(command.query, request);
|
|
4203
4229
|
await checkForm(command.form, request);
|
|
4204
4230
|
checkFormQuery(command.form, command.query);
|
|
4205
|
-
if (
|
|
4231
|
+
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
4232
|
return value;
|
|
4207
4233
|
}
|
|
4208
4234
|
async function parseAndVerifyManagedEngramExecution(raw, expected) {
|
|
4209
|
-
const value = ManagedEngramExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4235
|
+
const value = ManagedEngramExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4210
4236
|
const request = await parseAndVerifyEngramTrainingRequest(value.request);
|
|
4211
|
-
if (
|
|
4237
|
+
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
4238
|
if (value.sourceForm) await checkForm(value.sourceForm, request);
|
|
4213
4239
|
if (value.result) await parseAndVerifyEngramTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
4214
4240
|
return value;
|
|
@@ -4228,8 +4254,8 @@ async function parseAndVerifyManagedEngramPrepare(raw) {
|
|
|
4228
4254
|
}
|
|
4229
4255
|
async function parseAndVerifyManagedEngramExecutionReceipt(raw, command) {
|
|
4230
4256
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedEngramPrepare(command);
|
|
4231
|
-
const value = ManagedEngramExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4232
|
-
if (
|
|
4257
|
+
const value = ManagedEngramExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4258
|
+
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
4259
|
if ("action" in request) {
|
|
4234
4260
|
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
4261
|
} else {
|
|
@@ -4247,9 +4273,9 @@ function parseExecutionListQuery(raw = {}) {
|
|
|
4247
4273
|
));
|
|
4248
4274
|
}
|
|
4249
4275
|
async function parseAndVerifyManagedEngramExecutionPage(raw, expected) {
|
|
4250
|
-
const value = ManagedEngramExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4276
|
+
const value = ManagedEngramExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4251
4277
|
const query = parseExecutionListQuery(expected.query);
|
|
4252
|
-
if (
|
|
4278
|
+
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
4279
|
for (const item of value.items) {
|
|
4254
4280
|
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
4281
|
}
|
|
@@ -4295,62 +4321,62 @@ function createManagedEngramExecutionClient(request) {
|
|
|
4295
4321
|
}
|
|
4296
4322
|
|
|
4297
4323
|
// src/managed-decision-executions.ts
|
|
4298
|
-
import { z as
|
|
4324
|
+
import { z as z41 } from "zod";
|
|
4299
4325
|
import { assertBoundedTaskJson as assertBoundedTaskJson7 } from "@openpond/evals/task-schema";
|
|
4300
|
-
var Id25 =
|
|
4301
|
-
var Hash30 =
|
|
4302
|
-
var Money3 =
|
|
4303
|
-
var Method2 =
|
|
4304
|
-
var Mode =
|
|
4326
|
+
var Id25 = z41.string().trim().min(1).max(240);
|
|
4327
|
+
var Hash30 = z41.string().regex(/^[a-f0-9]{64}$/);
|
|
4328
|
+
var Money3 = z41.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4329
|
+
var Method2 = z41.literal("decision_model");
|
|
4330
|
+
var Mode = z41.enum(["train", "score"]);
|
|
4305
4331
|
var Query2 = ModelModificationCapabilitiesQuerySchema;
|
|
4306
|
-
var DecisionExecutionRequestSchema =
|
|
4307
|
-
var DecisionExecutionResultSchema =
|
|
4308
|
-
var DecisionExecutionCapabilityContentSchema =
|
|
4309
|
-
schemaVersion:
|
|
4332
|
+
var DecisionExecutionRequestSchema = z41.discriminatedUnion("schemaVersion", [DecisionTrainingRequestSchema, DecisionScoringRequestSchema]);
|
|
4333
|
+
var DecisionExecutionResultSchema = z41.discriminatedUnion("schemaVersion", [DecisionTrainingResultSchema, DecisionScoringResultSchema]);
|
|
4334
|
+
var DecisionExecutionCapabilityContentSchema = z41.object({
|
|
4335
|
+
schemaVersion: z41.literal("openpond.decisionExecutionCapability.v1"),
|
|
4310
4336
|
teamId: Id25,
|
|
4311
4337
|
actorId: Id25,
|
|
4312
4338
|
query: Query2,
|
|
4313
4339
|
requestHash: Hash30,
|
|
4314
|
-
checkedAt:
|
|
4315
|
-
expiresAt:
|
|
4340
|
+
checkedAt: z41.iso.datetime(),
|
|
4341
|
+
expiresAt: z41.iso.datetime(),
|
|
4316
4342
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4317
|
-
execution:
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
state:
|
|
4343
|
+
execution: z41.discriminatedUnion("state", [
|
|
4344
|
+
z41.object({ state: z41.literal("unavailable"), code: z41.enum(["model_not_supported", "runtime_not_qualified"]), reason: z41.string().min(1).max(1e3) }).strict(),
|
|
4345
|
+
z41.object({
|
|
4346
|
+
state: z41.literal("ready"),
|
|
4321
4347
|
model: DecisionModelIdentitySchema,
|
|
4322
|
-
runtime:
|
|
4348
|
+
runtime: z41.object({
|
|
4323
4349
|
id: Id25,
|
|
4324
4350
|
releaseHash: Hash30,
|
|
4325
|
-
imageDigest:
|
|
4326
|
-
requestSchemas:
|
|
4327
|
-
evidence:
|
|
4351
|
+
imageDigest: z41.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4352
|
+
requestSchemas: z41.tuple([z41.literal("openpond.decisionTrainingRequest.v1"), z41.literal("openpond.decisionScoringRequest.v1")]),
|
|
4353
|
+
evidence: z41.object({ id: Id25, contentHash: Hash30 }).strict()
|
|
4328
4354
|
}).strict(),
|
|
4329
|
-
limits:
|
|
4330
|
-
train:
|
|
4331
|
-
maximumExamples:
|
|
4332
|
-
maximumDataBytes:
|
|
4333
|
-
maximumSteps:
|
|
4334
|
-
maximumGradientAccumulationSteps:
|
|
4335
|
-
maximumPromptTokens:
|
|
4336
|
-
maximumForwardTokenWork:
|
|
4337
|
-
maximumDurationSeconds:
|
|
4338
|
-
maximumCheckpointBytes:
|
|
4355
|
+
limits: z41.object({
|
|
4356
|
+
train: z41.object({
|
|
4357
|
+
maximumExamples: z41.number().int().min(1).max(4096),
|
|
4358
|
+
maximumDataBytes: z41.number().int().positive().max(8388608),
|
|
4359
|
+
maximumSteps: z41.number().int().min(1).max(4096),
|
|
4360
|
+
maximumGradientAccumulationSteps: z41.number().int().min(1).max(64),
|
|
4361
|
+
maximumPromptTokens: z41.number().int().min(1).max(2048),
|
|
4362
|
+
maximumForwardTokenWork: z41.number().int().positive().max(536870912),
|
|
4363
|
+
maximumDurationSeconds: z41.number().finite().min(1).max(21600),
|
|
4364
|
+
maximumCheckpointBytes: z41.number().int().positive().max(268435456)
|
|
4339
4365
|
}).strict(),
|
|
4340
|
-
score:
|
|
4341
|
-
maximumQuestions:
|
|
4342
|
-
maximumChoicesPerQuestion:
|
|
4343
|
-
maximumStateBytes:
|
|
4344
|
-
maximumPromptTokens:
|
|
4345
|
-
maximumForwardTokenWork:
|
|
4346
|
-
maximumDurationSeconds:
|
|
4366
|
+
score: z41.object({
|
|
4367
|
+
maximumQuestions: z41.number().int().min(1).max(8),
|
|
4368
|
+
maximumChoicesPerQuestion: z41.number().int().min(2).max(26),
|
|
4369
|
+
maximumStateBytes: z41.number().int().positive().max(65536),
|
|
4370
|
+
maximumPromptTokens: z41.number().int().min(1).max(2048),
|
|
4371
|
+
maximumForwardTokenWork: z41.number().int().positive().max(65536),
|
|
4372
|
+
maximumDurationSeconds: z41.number().finite().positive().max(300)
|
|
4347
4373
|
}).strict()
|
|
4348
4374
|
}).strict()
|
|
4349
4375
|
}).strict()
|
|
4350
4376
|
])
|
|
4351
4377
|
}).strict();
|
|
4352
4378
|
var DecisionExecutionCapabilitySchema = DecisionExecutionCapabilityContentSchema.extend({ contentHash: Hash30 });
|
|
4353
|
-
var ManagedDecisionCompileSchema =
|
|
4379
|
+
var ManagedDecisionCompileSchema = z41.object({
|
|
4354
4380
|
teamId: Id25,
|
|
4355
4381
|
projectId: Id25.nullable(),
|
|
4356
4382
|
method: Method2,
|
|
@@ -4358,8 +4384,8 @@ var ManagedDecisionCompileSchema = z40.object({
|
|
|
4358
4384
|
query: Query2,
|
|
4359
4385
|
form: DecisionExperimentFormDraftSchema
|
|
4360
4386
|
}).strict();
|
|
4361
|
-
var ManagedDecisionCompilationContentSchema =
|
|
4362
|
-
schemaVersion:
|
|
4387
|
+
var ManagedDecisionCompilationContentSchema = z41.object({
|
|
4388
|
+
schemaVersion: z41.literal("openpond.managedDecisionCompilation.v1"),
|
|
4363
4389
|
teamId: Id25,
|
|
4364
4390
|
actorId: Id25,
|
|
4365
4391
|
projectId: Id25.nullable(),
|
|
@@ -4371,11 +4397,11 @@ var ManagedDecisionCompilationContentSchema = z40.object({
|
|
|
4371
4397
|
request: DecisionExecutionRequestSchema
|
|
4372
4398
|
}).strict();
|
|
4373
4399
|
var ManagedDecisionCompilationSchema = ManagedDecisionCompilationContentSchema.extend({ contentHash: Hash30 });
|
|
4374
|
-
var ManagedDecisionPrepareSchema =
|
|
4400
|
+
var ManagedDecisionPrepareSchema = z41.object({
|
|
4375
4401
|
teamId: Id25,
|
|
4376
4402
|
operationId: Id25,
|
|
4377
4403
|
projectId: Id25.nullable(),
|
|
4378
|
-
name:
|
|
4404
|
+
name: z41.string().trim().min(1).max(500),
|
|
4379
4405
|
method: Method2,
|
|
4380
4406
|
mode: Mode,
|
|
4381
4407
|
query: Query2,
|
|
@@ -4387,37 +4413,37 @@ var ManagedDecisionStartSchema = ManagedModificationStartSchema;
|
|
|
4387
4413
|
var ManagedDecisionCancelSchema = ManagedModificationCancelSchema;
|
|
4388
4414
|
var ManagedDecisionExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method2, mode: Mode }).strict();
|
|
4389
4415
|
var ManagedDecisionExecutionContentSchema = ManagedDecisionExecutionMetadataSchema.extend({
|
|
4390
|
-
schemaVersion:
|
|
4416
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecution.v1"),
|
|
4391
4417
|
request: DecisionExecutionRequestSchema,
|
|
4392
4418
|
sourceForm: DecisionExperimentFormDraftSchema.optional(),
|
|
4393
4419
|
result: DecisionExecutionResultSchema.nullable(),
|
|
4394
|
-
resultRecordedAt:
|
|
4420
|
+
resultRecordedAt: z41.iso.datetime().nullable()
|
|
4395
4421
|
}).strict();
|
|
4396
4422
|
var ManagedDecisionExecutionSchema = ManagedDecisionExecutionContentSchema.extend({ contentHash: Hash30 });
|
|
4397
|
-
var ManagedDecisionExecutionReceiptContentSchema =
|
|
4398
|
-
schemaVersion:
|
|
4423
|
+
var ManagedDecisionExecutionReceiptContentSchema = z41.object({
|
|
4424
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecutionReceipt.v1"),
|
|
4399
4425
|
operationId: Id25,
|
|
4400
4426
|
requestHash: Hash30,
|
|
4401
4427
|
execution: ManagedDecisionExecutionMetadataSchema
|
|
4402
4428
|
}).strict();
|
|
4403
4429
|
var ManagedDecisionExecutionReceiptSchema = ManagedDecisionExecutionReceiptContentSchema.extend({ contentHash: Hash30 });
|
|
4404
|
-
var ManagedDecisionExecutionListQuerySchema =
|
|
4430
|
+
var ManagedDecisionExecutionListQuerySchema = z41.object({
|
|
4405
4431
|
method: Method2.default("decision_model"),
|
|
4406
4432
|
mode: Mode.optional(),
|
|
4407
4433
|
id: Id25.optional(),
|
|
4408
4434
|
projectId: Id25.optional(),
|
|
4409
4435
|
phase: ManagedDecisionExecutionMetadataSchema.shape.phase.optional(),
|
|
4410
|
-
limit:
|
|
4411
|
-
cursor:
|
|
4436
|
+
limit: z41.number().int().min(1).max(100).default(25),
|
|
4437
|
+
cursor: z41.string().min(1).max(2048).optional()
|
|
4412
4438
|
}).strict();
|
|
4413
4439
|
var ManagedDecisionExecutionSummarySchema = ManagedDecisionExecutionMetadataSchema.extend({ model: DecisionModelIdentitySchema }).strict();
|
|
4414
|
-
var ManagedDecisionExecutionPageContentSchema =
|
|
4415
|
-
schemaVersion:
|
|
4440
|
+
var ManagedDecisionExecutionPageContentSchema = z41.object({
|
|
4441
|
+
schemaVersion: z41.literal("openpond.managedDecisionExecutionPage.v1"),
|
|
4416
4442
|
teamId: Id25,
|
|
4417
4443
|
ownerUserId: Id25,
|
|
4418
4444
|
query: ManagedDecisionExecutionListQuerySchema,
|
|
4419
|
-
items:
|
|
4420
|
-
nextCursor:
|
|
4445
|
+
items: z41.array(ManagedDecisionExecutionSummarySchema).max(100),
|
|
4446
|
+
nextCursor: z41.string().min(1).max(2048).nullable()
|
|
4421
4447
|
}).strict();
|
|
4422
4448
|
var ManagedDecisionExecutionPageSchema = ManagedDecisionExecutionPageContentSchema.extend({ contentHash: Hash30 });
|
|
4423
4449
|
function fail4() {
|
|
@@ -4485,10 +4511,10 @@ function checkPlan(metadata) {
|
|
|
4485
4511
|
if (metadata.plan.maximumSpendUsd !== canonicalComputeSpendCap(metadata.plan.maximumSpendUsd) || Date.parse(metadata.plan.expiresAt) <= Date.parse(metadata.plan.createdAt)) fail4();
|
|
4486
4512
|
}
|
|
4487
4513
|
async function parseAndVerifyDecisionExecutionCapability(raw, input, actorId) {
|
|
4488
|
-
const query = Query2.parse(input), value = DecisionExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4514
|
+
const query = Query2.parse(input), value = DecisionExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4489
4515
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4490
4516
|
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) ||
|
|
4517
|
+
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
4518
|
if (value.execution.state === "ready") {
|
|
4493
4519
|
await parseAndVerifyDecisionModelIdentity(value.execution.model);
|
|
4494
4520
|
checkSource2(query, value.execution.model);
|
|
@@ -4523,11 +4549,11 @@ function parseManagedDecisionCompile(raw) {
|
|
|
4523
4549
|
return value;
|
|
4524
4550
|
}
|
|
4525
4551
|
async function parseAndVerifyManagedDecisionCompilation(raw, input, actorId) {
|
|
4526
|
-
const command = parseManagedDecisionCompile(input), value = ManagedDecisionCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4552
|
+
const command = parseManagedDecisionCompile(input), value = ManagedDecisionCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4527
4553
|
const request = await verifyRequest(value.request);
|
|
4528
4554
|
checkSource2(command.query, request.model);
|
|
4529
4555
|
await checkForm2(command.form, request);
|
|
4530
|
-
if (
|
|
4556
|
+
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
4557
|
return value;
|
|
4532
4558
|
}
|
|
4533
4559
|
async function parseAndVerifyManagedDecisionPrepare(raw) {
|
|
@@ -4545,10 +4571,10 @@ async function parseAndVerifyManagedDecisionPrepare(raw) {
|
|
|
4545
4571
|
}
|
|
4546
4572
|
async function parseAndVerifyManagedDecisionExecution(raw, expected) {
|
|
4547
4573
|
assertBoundedTaskJson7(raw, 1048576);
|
|
4548
|
-
const value = ManagedDecisionExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4574
|
+
const value = ManagedDecisionExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4549
4575
|
const request = await verifyRequest(value.request);
|
|
4550
4576
|
checkPlan(value);
|
|
4551
|
-
if (
|
|
4577
|
+
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
4578
|
if (value.sourceForm) {
|
|
4553
4579
|
await checkForm2(value.sourceForm, request);
|
|
4554
4580
|
if (value.sourceForm.name.trim() !== value.name || canonicalComputeSpendCap(value.sourceForm.maximumSpendUsd) !== value.plan.maximumSpendUsd) fail4();
|
|
@@ -4564,10 +4590,10 @@ async function parseAndVerifyManagedDecisionExecution(raw, expected) {
|
|
|
4564
4590
|
}
|
|
4565
4591
|
async function parseAndVerifyManagedDecisionExecutionReceipt(raw, input, ownerUserId) {
|
|
4566
4592
|
const command = "action" in input ? parseManagedModificationControl(input) : await parseAndVerifyManagedDecisionPrepare(input);
|
|
4567
|
-
const value = ManagedDecisionExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4593
|
+
const value = ManagedDecisionExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4568
4594
|
const metadata = value.execution;
|
|
4569
4595
|
checkPlan(metadata);
|
|
4570
|
-
if (
|
|
4596
|
+
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
4597
|
if ("action" in command) {
|
|
4572
4598
|
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
4599
|
} 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 +4606,9 @@ function parseExecutionListQuery2(raw = {}) {
|
|
|
4580
4606
|
));
|
|
4581
4607
|
}
|
|
4582
4608
|
async function parseAndVerifyManagedDecisionExecutionPage(raw, expected) {
|
|
4583
|
-
const value = ManagedDecisionExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4609
|
+
const value = ManagedDecisionExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4584
4610
|
const query = parseExecutionListQuery2(expected.query);
|
|
4585
|
-
if (
|
|
4611
|
+
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
4612
|
for (const [index, item] of value.items.entries()) {
|
|
4587
4613
|
const previous = value.items[index - 1];
|
|
4588
4614
|
checkPlan(item);
|
|
@@ -4631,54 +4657,54 @@ function createManagedDecisionExecutionClient(request) {
|
|
|
4631
4657
|
}
|
|
4632
4658
|
|
|
4633
4659
|
// src/managed-alphaedit-executions.ts
|
|
4634
|
-
import { z as
|
|
4635
|
-
var Id26 =
|
|
4636
|
-
var Hash31 =
|
|
4637
|
-
var Money4 =
|
|
4638
|
-
var Method3 =
|
|
4660
|
+
import { z as z42 } from "zod";
|
|
4661
|
+
var Id26 = z42.string().trim().min(1).max(240);
|
|
4662
|
+
var Hash31 = z42.string().regex(/^[a-f0-9]{64}$/);
|
|
4663
|
+
var Money4 = z42.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4664
|
+
var Method3 = z42.literal("alphaedit");
|
|
4639
4665
|
var Query3 = ModelModificationCapabilitiesQuerySchema;
|
|
4640
|
-
var AlphaEditExecutionCapabilityContentSchema =
|
|
4641
|
-
schemaVersion:
|
|
4666
|
+
var AlphaEditExecutionCapabilityContentSchema = z42.object({
|
|
4667
|
+
schemaVersion: z42.literal("openpond.alphaEditExecutionCapability.v1"),
|
|
4642
4668
|
teamId: Id26,
|
|
4643
4669
|
actorId: Id26,
|
|
4644
4670
|
query: Query3,
|
|
4645
4671
|
requestHash: Hash31,
|
|
4646
|
-
checkedAt:
|
|
4647
|
-
expiresAt:
|
|
4672
|
+
checkedAt: z42.iso.datetime(),
|
|
4673
|
+
expiresAt: z42.iso.datetime(),
|
|
4648
4674
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4649
|
-
execution:
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
state:
|
|
4675
|
+
execution: z42.discriminatedUnion("state", [
|
|
4676
|
+
z42.object({ state: z42.literal("unavailable"), code: z42.enum(["model_not_supported", "runtime_not_qualified"]), reason: z42.string().min(1).max(1e3) }).strict(),
|
|
4677
|
+
z42.object({
|
|
4678
|
+
state: z42.literal("ready"),
|
|
4653
4679
|
model: NeuronSteeringModelSchema,
|
|
4654
|
-
runtime:
|
|
4680
|
+
runtime: z42.object({
|
|
4655
4681
|
id: Id26,
|
|
4656
4682
|
releaseHash: Hash31,
|
|
4657
|
-
imageDigest:
|
|
4658
|
-
requestSchema:
|
|
4659
|
-
evidence:
|
|
4683
|
+
imageDigest: z42.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4684
|
+
requestSchema: z42.literal("openpond.alphaEditTrainingRequest.v1"),
|
|
4685
|
+
evidence: z42.object({ id: Id26, contentHash: Hash31 }).strict()
|
|
4660
4686
|
}).strict(),
|
|
4661
|
-
limits:
|
|
4662
|
-
maximumExamples:
|
|
4663
|
-
maximumDataBytes:
|
|
4664
|
-
maximumSteps:
|
|
4665
|
-
maximumSequenceLength:
|
|
4666
|
-
maximumDurationSeconds:
|
|
4667
|
-
maximumCheckpointBytes:
|
|
4687
|
+
limits: z42.object({
|
|
4688
|
+
maximumExamples: z42.number().int().min(1).max(4096),
|
|
4689
|
+
maximumDataBytes: z42.number().int().positive().max(8388608),
|
|
4690
|
+
maximumSteps: z42.number().int().min(1).max(128),
|
|
4691
|
+
maximumSequenceLength: z42.number().int().min(2).max(8192),
|
|
4692
|
+
maximumDurationSeconds: z42.number().finite().min(1).max(21600),
|
|
4693
|
+
maximumCheckpointBytes: z42.number().int().positive().max(17179869184)
|
|
4668
4694
|
}).strict()
|
|
4669
4695
|
}).strict()
|
|
4670
4696
|
])
|
|
4671
4697
|
}).strict();
|
|
4672
4698
|
var AlphaEditExecutionCapabilitySchema = AlphaEditExecutionCapabilityContentSchema.extend({ contentHash: Hash31 });
|
|
4673
|
-
var ManagedAlphaEditCompileSchema =
|
|
4699
|
+
var ManagedAlphaEditCompileSchema = z42.object({
|
|
4674
4700
|
teamId: Id26,
|
|
4675
4701
|
projectId: Id26.nullable(),
|
|
4676
4702
|
method: Method3,
|
|
4677
4703
|
query: Query3,
|
|
4678
4704
|
form: AlphaEditExperimentFormDraftSchema
|
|
4679
4705
|
}).strict();
|
|
4680
|
-
var ManagedAlphaEditCompilationContentSchema =
|
|
4681
|
-
schemaVersion:
|
|
4706
|
+
var ManagedAlphaEditCompilationContentSchema = z42.object({
|
|
4707
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditCompilation.v1"),
|
|
4682
4708
|
teamId: Id26,
|
|
4683
4709
|
actorId: Id26,
|
|
4684
4710
|
projectId: Id26.nullable(),
|
|
@@ -4689,11 +4715,11 @@ var ManagedAlphaEditCompilationContentSchema = z41.object({
|
|
|
4689
4715
|
request: AlphaEditTrainingRequestSchema
|
|
4690
4716
|
}).strict();
|
|
4691
4717
|
var ManagedAlphaEditCompilationSchema = ManagedAlphaEditCompilationContentSchema.extend({ contentHash: Hash31 });
|
|
4692
|
-
var ManagedAlphaEditPrepareSchema =
|
|
4718
|
+
var ManagedAlphaEditPrepareSchema = z42.object({
|
|
4693
4719
|
teamId: Id26,
|
|
4694
4720
|
operationId: Id26,
|
|
4695
4721
|
projectId: Id26.nullable(),
|
|
4696
|
-
name:
|
|
4722
|
+
name: z42.string().trim().min(1).max(500),
|
|
4697
4723
|
method: Method3,
|
|
4698
4724
|
query: Query3,
|
|
4699
4725
|
request: AlphaEditTrainingRequestSchema,
|
|
@@ -4704,36 +4730,36 @@ var ManagedAlphaEditStartSchema = ManagedModificationStartSchema;
|
|
|
4704
4730
|
var ManagedAlphaEditCancelSchema = ManagedModificationCancelSchema;
|
|
4705
4731
|
var ManagedAlphaEditExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method3 }).strict();
|
|
4706
4732
|
var ManagedAlphaEditExecutionContentSchema = ManagedAlphaEditExecutionMetadataSchema.extend({
|
|
4707
|
-
schemaVersion:
|
|
4733
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecution.v1"),
|
|
4708
4734
|
request: AlphaEditTrainingRequestSchema,
|
|
4709
4735
|
sourceForm: AlphaEditExperimentFormDraftSchema.optional(),
|
|
4710
4736
|
result: AlphaEditTrainingResultSchema.nullable(),
|
|
4711
|
-
resultRecordedAt:
|
|
4737
|
+
resultRecordedAt: z42.iso.datetime().nullable()
|
|
4712
4738
|
}).strict();
|
|
4713
4739
|
var ManagedAlphaEditExecutionSchema = ManagedAlphaEditExecutionContentSchema.extend({ contentHash: Hash31 });
|
|
4714
|
-
var ManagedAlphaEditExecutionReceiptContentSchema =
|
|
4715
|
-
schemaVersion:
|
|
4740
|
+
var ManagedAlphaEditExecutionReceiptContentSchema = z42.object({
|
|
4741
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecutionReceipt.v1"),
|
|
4716
4742
|
operationId: Id26,
|
|
4717
4743
|
requestHash: Hash31,
|
|
4718
4744
|
execution: ManagedAlphaEditExecutionMetadataSchema
|
|
4719
4745
|
}).strict();
|
|
4720
4746
|
var ManagedAlphaEditExecutionReceiptSchema = ManagedAlphaEditExecutionReceiptContentSchema.extend({ contentHash: Hash31 });
|
|
4721
|
-
var ManagedAlphaEditExecutionListQuerySchema =
|
|
4747
|
+
var ManagedAlphaEditExecutionListQuerySchema = z42.object({
|
|
4722
4748
|
method: Method3.default("alphaedit"),
|
|
4723
4749
|
id: Id26.optional(),
|
|
4724
4750
|
projectId: Id26.optional(),
|
|
4725
4751
|
phase: ManagedAlphaEditExecutionMetadataSchema.shape.phase.optional(),
|
|
4726
|
-
limit:
|
|
4727
|
-
cursor:
|
|
4752
|
+
limit: z42.number().int().min(1).max(100).default(25),
|
|
4753
|
+
cursor: z42.string().min(1).max(2048).optional()
|
|
4728
4754
|
}).strict();
|
|
4729
4755
|
var ManagedAlphaEditExecutionSummarySchema = ManagedAlphaEditExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4730
|
-
var ManagedAlphaEditExecutionPageContentSchema =
|
|
4731
|
-
schemaVersion:
|
|
4756
|
+
var ManagedAlphaEditExecutionPageContentSchema = z42.object({
|
|
4757
|
+
schemaVersion: z42.literal("openpond.managedAlphaEditExecutionPage.v1"),
|
|
4732
4758
|
teamId: Id26,
|
|
4733
4759
|
ownerUserId: Id26,
|
|
4734
4760
|
query: ManagedAlphaEditExecutionListQuerySchema,
|
|
4735
|
-
items:
|
|
4736
|
-
nextCursor:
|
|
4761
|
+
items: z42.array(ManagedAlphaEditExecutionSummarySchema).max(100),
|
|
4762
|
+
nextCursor: z42.string().min(1).max(2048).nullable()
|
|
4737
4763
|
}).strict();
|
|
4738
4764
|
var ManagedAlphaEditExecutionPageSchema = ManagedAlphaEditExecutionPageContentSchema.extend({ contentHash: Hash31 });
|
|
4739
4765
|
function parseAlphaEditFormTraining(raw) {
|
|
@@ -4786,26 +4812,26 @@ function checkFormQuery2(form, query) {
|
|
|
4786
4812
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail5();
|
|
4787
4813
|
}
|
|
4788
4814
|
async function parseAndVerifyAlphaEditExecutionCapability(raw, queryInput, actorId) {
|
|
4789
|
-
const query = Query3.parse(queryInput), value = AlphaEditExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
4815
|
+
const query = Query3.parse(queryInput), value = AlphaEditExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4790
4816
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
4791
4817
|
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) ||
|
|
4818
|
+
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
4819
|
if (value.execution.state === "ready") checkSource3(query, { model: value.execution.model });
|
|
4794
4820
|
return value;
|
|
4795
4821
|
}
|
|
4796
4822
|
async function parseAndVerifyManagedAlphaEditCompilation(raw, input) {
|
|
4797
|
-
const command = ManagedAlphaEditCompileSchema.parse(input), value = ManagedAlphaEditCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
4823
|
+
const command = ManagedAlphaEditCompileSchema.parse(input), value = ManagedAlphaEditCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4798
4824
|
const request = await parseAndVerifyAlphaEditTrainingRequest(value.request);
|
|
4799
4825
|
checkSource3(command.query, request);
|
|
4800
4826
|
await checkForm3(command.form, request);
|
|
4801
4827
|
checkFormQuery2(command.form, command.query);
|
|
4802
|
-
if (
|
|
4828
|
+
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
4829
|
return value;
|
|
4804
4830
|
}
|
|
4805
4831
|
async function parseAndVerifyManagedAlphaEditExecution(raw, expected) {
|
|
4806
|
-
const value = ManagedAlphaEditExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
4832
|
+
const value = ManagedAlphaEditExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4807
4833
|
const request = await parseAndVerifyAlphaEditTrainingRequest(value.request);
|
|
4808
|
-
if (
|
|
4834
|
+
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
4835
|
if (value.sourceForm) await checkForm3(value.sourceForm, request);
|
|
4810
4836
|
if (value.result) await parseAndVerifyAlphaEditTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
4811
4837
|
return value;
|
|
@@ -4825,8 +4851,8 @@ async function parseAndVerifyManagedAlphaEditPrepare(raw) {
|
|
|
4825
4851
|
}
|
|
4826
4852
|
async function parseAndVerifyManagedAlphaEditExecutionReceipt(raw, command) {
|
|
4827
4853
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedAlphaEditPrepare(command);
|
|
4828
|
-
const value = ManagedAlphaEditExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
4829
|
-
if (
|
|
4854
|
+
const value = ManagedAlphaEditExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4855
|
+
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
4856
|
if ("action" in request) {
|
|
4831
4857
|
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
4858
|
} else {
|
|
@@ -4844,9 +4870,9 @@ function parseExecutionListQuery3(raw = {}) {
|
|
|
4844
4870
|
));
|
|
4845
4871
|
}
|
|
4846
4872
|
async function parseAndVerifyManagedAlphaEditExecutionPage(raw, expected) {
|
|
4847
|
-
const value = ManagedAlphaEditExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
4873
|
+
const value = ManagedAlphaEditExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
4848
4874
|
const query = parseExecutionListQuery3(expected.query);
|
|
4849
|
-
if (
|
|
4875
|
+
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
4876
|
for (const item of value.items) {
|
|
4851
4877
|
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
4878
|
}
|
|
@@ -4892,54 +4918,54 @@ function createManagedAlphaEditExecutionClient(request) {
|
|
|
4892
4918
|
}
|
|
4893
4919
|
|
|
4894
4920
|
// src/managed-neuron-training-executions.ts
|
|
4895
|
-
import { z as
|
|
4896
|
-
var Id27 =
|
|
4897
|
-
var Hash32 =
|
|
4898
|
-
var Money5 =
|
|
4899
|
-
var Method4 =
|
|
4921
|
+
import { z as z43 } from "zod";
|
|
4922
|
+
var Id27 = z43.string().trim().min(1).max(240);
|
|
4923
|
+
var Hash32 = z43.string().regex(/^[a-f0-9]{64}$/);
|
|
4924
|
+
var Money5 = z43.string().regex(/^(0|[1-9]\d*)(\.\d{1,6})?$/).max(48);
|
|
4925
|
+
var Method4 = z43.literal("selective_neuron_training");
|
|
4900
4926
|
var Query4 = ModelModificationCapabilitiesQuerySchema;
|
|
4901
|
-
var NeuronTrainingExecutionCapabilityContentSchema =
|
|
4902
|
-
schemaVersion:
|
|
4927
|
+
var NeuronTrainingExecutionCapabilityContentSchema = z43.object({
|
|
4928
|
+
schemaVersion: z43.literal("openpond.neuronTrainingExecutionCapability.v1"),
|
|
4903
4929
|
teamId: Id27,
|
|
4904
4930
|
actorId: Id27,
|
|
4905
4931
|
query: Query4,
|
|
4906
4932
|
requestHash: Hash32,
|
|
4907
|
-
checkedAt:
|
|
4908
|
-
expiresAt:
|
|
4933
|
+
checkedAt: z43.iso.datetime(),
|
|
4934
|
+
expiresAt: z43.iso.datetime(),
|
|
4909
4935
|
validationLevel: ModelModificationValidationLevelSchema.nullable(),
|
|
4910
|
-
execution:
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
state:
|
|
4936
|
+
execution: z43.discriminatedUnion("state", [
|
|
4937
|
+
z43.object({ state: z43.literal("unavailable"), code: z43.enum(["model_not_supported", "runtime_not_qualified"]), reason: z43.string().min(1).max(1e3) }).strict(),
|
|
4938
|
+
z43.object({
|
|
4939
|
+
state: z43.literal("ready"),
|
|
4914
4940
|
model: NeuronSteeringModelSchema,
|
|
4915
|
-
runtime:
|
|
4941
|
+
runtime: z43.object({
|
|
4916
4942
|
id: Id27,
|
|
4917
4943
|
releaseHash: Hash32,
|
|
4918
|
-
imageDigest:
|
|
4919
|
-
requestSchema:
|
|
4920
|
-
evidence:
|
|
4944
|
+
imageDigest: z43.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4945
|
+
requestSchema: z43.literal("openpond.selectiveNeuronTrainingRequest.v1"),
|
|
4946
|
+
evidence: z43.object({ id: Id27, contentHash: Hash32 }).strict()
|
|
4921
4947
|
}).strict(),
|
|
4922
|
-
limits:
|
|
4923
|
-
maximumExamples:
|
|
4924
|
-
maximumDataBytes:
|
|
4925
|
-
maximumSteps:
|
|
4926
|
-
maximumSequenceLength:
|
|
4927
|
-
maximumDurationSeconds:
|
|
4928
|
-
maximumCheckpointBytes:
|
|
4948
|
+
limits: z43.object({
|
|
4949
|
+
maximumExamples: z43.number().int().min(1).max(4096),
|
|
4950
|
+
maximumDataBytes: z43.number().int().positive().max(8388608),
|
|
4951
|
+
maximumSteps: z43.number().int().min(1).max(128),
|
|
4952
|
+
maximumSequenceLength: z43.number().int().min(2).max(8192),
|
|
4953
|
+
maximumDurationSeconds: z43.number().finite().min(1).max(21600),
|
|
4954
|
+
maximumCheckpointBytes: z43.number().int().positive().max(16777216)
|
|
4929
4955
|
}).strict()
|
|
4930
4956
|
}).strict()
|
|
4931
4957
|
])
|
|
4932
4958
|
}).strict();
|
|
4933
4959
|
var NeuronTrainingExecutionCapabilitySchema = NeuronTrainingExecutionCapabilityContentSchema.extend({ contentHash: Hash32 });
|
|
4934
|
-
var ManagedNeuronTrainingCompileSchema =
|
|
4960
|
+
var ManagedNeuronTrainingCompileSchema = z43.object({
|
|
4935
4961
|
teamId: Id27,
|
|
4936
4962
|
projectId: Id27.nullable(),
|
|
4937
4963
|
method: Method4,
|
|
4938
4964
|
query: Query4,
|
|
4939
4965
|
form: NeuronTrainingExperimentFormDraftSchema
|
|
4940
4966
|
}).strict();
|
|
4941
|
-
var ManagedNeuronTrainingCompilationContentSchema =
|
|
4942
|
-
schemaVersion:
|
|
4967
|
+
var ManagedNeuronTrainingCompilationContentSchema = z43.object({
|
|
4968
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingCompilation.v1"),
|
|
4943
4969
|
teamId: Id27,
|
|
4944
4970
|
actorId: Id27,
|
|
4945
4971
|
projectId: Id27.nullable(),
|
|
@@ -4950,11 +4976,11 @@ var ManagedNeuronTrainingCompilationContentSchema = z42.object({
|
|
|
4950
4976
|
request: NeuronTrainingRequestSchema
|
|
4951
4977
|
}).strict();
|
|
4952
4978
|
var ManagedNeuronTrainingCompilationSchema = ManagedNeuronTrainingCompilationContentSchema.extend({ contentHash: Hash32 });
|
|
4953
|
-
var ManagedNeuronTrainingPrepareSchema =
|
|
4979
|
+
var ManagedNeuronTrainingPrepareSchema = z43.object({
|
|
4954
4980
|
teamId: Id27,
|
|
4955
4981
|
operationId: Id27,
|
|
4956
4982
|
projectId: Id27.nullable(),
|
|
4957
|
-
name:
|
|
4983
|
+
name: z43.string().trim().min(1).max(500),
|
|
4958
4984
|
method: Method4,
|
|
4959
4985
|
query: Query4,
|
|
4960
4986
|
request: NeuronTrainingRequestSchema,
|
|
@@ -4965,36 +4991,36 @@ var ManagedNeuronTrainingStartSchema = ManagedModificationStartSchema;
|
|
|
4965
4991
|
var ManagedNeuronTrainingCancelSchema = ManagedModificationCancelSchema;
|
|
4966
4992
|
var ManagedNeuronTrainingExecutionMetadataSchema = ManagedModificationExecutionMetadataSchema.omit({ method: true }).extend({ method: Method4 }).strict();
|
|
4967
4993
|
var ManagedNeuronTrainingExecutionContentSchema = ManagedNeuronTrainingExecutionMetadataSchema.extend({
|
|
4968
|
-
schemaVersion:
|
|
4994
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecution.v1"),
|
|
4969
4995
|
request: NeuronTrainingRequestSchema,
|
|
4970
4996
|
sourceForm: NeuronTrainingExperimentFormDraftSchema.optional(),
|
|
4971
4997
|
result: NeuronTrainingResultSchema.nullable(),
|
|
4972
|
-
resultRecordedAt:
|
|
4998
|
+
resultRecordedAt: z43.iso.datetime().nullable()
|
|
4973
4999
|
}).strict();
|
|
4974
5000
|
var ManagedNeuronTrainingExecutionSchema = ManagedNeuronTrainingExecutionContentSchema.extend({ contentHash: Hash32 });
|
|
4975
|
-
var ManagedNeuronTrainingExecutionReceiptContentSchema =
|
|
4976
|
-
schemaVersion:
|
|
5001
|
+
var ManagedNeuronTrainingExecutionReceiptContentSchema = z43.object({
|
|
5002
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecutionReceipt.v1"),
|
|
4977
5003
|
operationId: Id27,
|
|
4978
5004
|
requestHash: Hash32,
|
|
4979
5005
|
execution: ManagedNeuronTrainingExecutionMetadataSchema
|
|
4980
5006
|
}).strict();
|
|
4981
5007
|
var ManagedNeuronTrainingExecutionReceiptSchema = ManagedNeuronTrainingExecutionReceiptContentSchema.extend({ contentHash: Hash32 });
|
|
4982
|
-
var ManagedNeuronTrainingExecutionListQuerySchema =
|
|
5008
|
+
var ManagedNeuronTrainingExecutionListQuerySchema = z43.object({
|
|
4983
5009
|
method: Method4.default("selective_neuron_training"),
|
|
4984
5010
|
id: Id27.optional(),
|
|
4985
5011
|
projectId: Id27.optional(),
|
|
4986
5012
|
phase: ManagedNeuronTrainingExecutionMetadataSchema.shape.phase.optional(),
|
|
4987
|
-
limit:
|
|
4988
|
-
cursor:
|
|
5013
|
+
limit: z43.number().int().min(1).max(100).default(25),
|
|
5014
|
+
cursor: z43.string().min(1).max(2048).optional()
|
|
4989
5015
|
}).strict();
|
|
4990
5016
|
var ManagedNeuronTrainingExecutionSummarySchema = ManagedNeuronTrainingExecutionMetadataSchema.extend({ model: NeuronSteeringModelSchema }).strict();
|
|
4991
|
-
var ManagedNeuronTrainingExecutionPageContentSchema =
|
|
4992
|
-
schemaVersion:
|
|
5017
|
+
var ManagedNeuronTrainingExecutionPageContentSchema = z43.object({
|
|
5018
|
+
schemaVersion: z43.literal("openpond.managedNeuronTrainingExecutionPage.v1"),
|
|
4993
5019
|
teamId: Id27,
|
|
4994
5020
|
ownerUserId: Id27,
|
|
4995
5021
|
query: ManagedNeuronTrainingExecutionListQuerySchema,
|
|
4996
|
-
items:
|
|
4997
|
-
nextCursor:
|
|
5022
|
+
items: z43.array(ManagedNeuronTrainingExecutionSummarySchema).max(100),
|
|
5023
|
+
nextCursor: z43.string().min(1).max(2048).nullable()
|
|
4998
5024
|
}).strict();
|
|
4999
5025
|
var ManagedNeuronTrainingExecutionPageSchema = ManagedNeuronTrainingExecutionPageContentSchema.extend({ contentHash: Hash32 });
|
|
5000
5026
|
function parseNeuronTrainingFormTraining(raw) {
|
|
@@ -5046,26 +5072,26 @@ function checkFormQuery3(form, query) {
|
|
|
5046
5072
|
if (canonicalJson(form.baseModel) !== canonicalJson(base)) fail6();
|
|
5047
5073
|
}
|
|
5048
5074
|
async function parseAndVerifyNeuronTrainingExecutionCapability(raw, queryInput, actorId) {
|
|
5049
|
-
const query = Query4.parse(queryInput), value = NeuronTrainingExecutionCapabilitySchema.parse(raw), { contentHash, ...content } = value;
|
|
5075
|
+
const query = Query4.parse(queryInput), value = NeuronTrainingExecutionCapabilitySchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5050
5076
|
assertModelModificationValidationLevel(value.execution, value.validationLevel);
|
|
5051
5077
|
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) ||
|
|
5078
|
+
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
5079
|
if (value.execution.state === "ready") checkSource4(query, { model: value.execution.model });
|
|
5054
5080
|
return value;
|
|
5055
5081
|
}
|
|
5056
5082
|
async function parseAndVerifyManagedNeuronTrainingCompilation(raw, input) {
|
|
5057
|
-
const command = ManagedNeuronTrainingCompileSchema.parse(input), value = ManagedNeuronTrainingCompilationSchema.parse(raw), { contentHash, ...content } = value;
|
|
5083
|
+
const command = ManagedNeuronTrainingCompileSchema.parse(input), value = ManagedNeuronTrainingCompilationSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5058
5084
|
const request = await parseAndVerifyNeuronTrainingRequest(value.request);
|
|
5059
5085
|
checkSource4(command.query, request);
|
|
5060
5086
|
await checkForm4(command.form, request);
|
|
5061
5087
|
checkFormQuery3(command.form, command.query);
|
|
5062
|
-
if (
|
|
5088
|
+
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
5089
|
return value;
|
|
5064
5090
|
}
|
|
5065
5091
|
async function parseAndVerifyManagedNeuronTrainingExecution(raw, expected) {
|
|
5066
|
-
const value = ManagedNeuronTrainingExecutionSchema.parse(raw), { contentHash, ...content } = value;
|
|
5092
|
+
const value = ManagedNeuronTrainingExecutionSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5067
5093
|
const request = await parseAndVerifyNeuronTrainingRequest(value.request);
|
|
5068
|
-
if (
|
|
5094
|
+
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
5095
|
if (value.sourceForm) await checkForm4(value.sourceForm, request);
|
|
5070
5096
|
if (value.result) await parseAndVerifyNeuronTrainingResult(value.result, { request, runtimeHash: value.plan.runtimeHash });
|
|
5071
5097
|
return value;
|
|
@@ -5085,8 +5111,8 @@ async function parseAndVerifyManagedNeuronTrainingPrepare(raw) {
|
|
|
5085
5111
|
}
|
|
5086
5112
|
async function parseAndVerifyManagedNeuronTrainingExecutionReceipt(raw, command) {
|
|
5087
5113
|
const request = "action" in command ? parseManagedModificationControl(command) : await parseAndVerifyManagedNeuronTrainingPrepare(command);
|
|
5088
|
-
const value = ManagedNeuronTrainingExecutionReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5089
|
-
if (
|
|
5114
|
+
const value = ManagedNeuronTrainingExecutionReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5115
|
+
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
5116
|
if ("action" in request) {
|
|
5091
5117
|
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
5118
|
} else {
|
|
@@ -5104,9 +5130,9 @@ function parseExecutionListQuery4(raw = {}) {
|
|
|
5104
5130
|
));
|
|
5105
5131
|
}
|
|
5106
5132
|
async function parseAndVerifyManagedNeuronTrainingExecutionPage(raw, expected) {
|
|
5107
|
-
const value = ManagedNeuronTrainingExecutionPageSchema.parse(raw), { contentHash, ...content } = value;
|
|
5133
|
+
const value = ManagedNeuronTrainingExecutionPageSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5108
5134
|
const query = parseExecutionListQuery4(expected.query);
|
|
5109
|
-
if (
|
|
5135
|
+
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
5136
|
for (const item of value.items) {
|
|
5111
5137
|
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
5138
|
}
|
|
@@ -5152,18 +5178,18 @@ function createManagedNeuronTrainingExecutionClient(request) {
|
|
|
5152
5178
|
}
|
|
5153
5179
|
|
|
5154
5180
|
// src/alphaedit-model-serving.ts
|
|
5155
|
-
import { z as
|
|
5181
|
+
import { z as z45 } from "zod";
|
|
5156
5182
|
|
|
5157
5183
|
// src/weight-inference.ts
|
|
5158
|
-
import { z as
|
|
5159
|
-
var Id28 =
|
|
5160
|
-
var Hash33 =
|
|
5161
|
-
var SavedWeightModelSelectionSchema =
|
|
5162
|
-
var ResolvedWeightModelSelectionSchema =
|
|
5163
|
-
schemaVersion:
|
|
5164
|
-
method:
|
|
5184
|
+
import { z as z44 } from "zod";
|
|
5185
|
+
var Id28 = z44.string().trim().min(1).max(240);
|
|
5186
|
+
var Hash33 = z44.string().regex(/^[a-f0-9]{64}$/);
|
|
5187
|
+
var SavedWeightModelSelectionSchema = z44.object({ modelProjectId: Id28, versionHash: Hash33 }).strict();
|
|
5188
|
+
var ResolvedWeightModelSelectionSchema = z44.object({
|
|
5189
|
+
schemaVersion: z44.literal("openpond.resolvedWeightModelSelection.v1"),
|
|
5190
|
+
method: z44.enum(["alphaedit", "selective_neuron_training"]),
|
|
5165
5191
|
savedModel: SavedWeightModelSelectionSchema,
|
|
5166
|
-
artifact:
|
|
5192
|
+
artifact: z44.object({ id: Id28, contentHash: Hash33, manifestSha256: Hash33 }).strict(),
|
|
5167
5193
|
modelHash: Hash33
|
|
5168
5194
|
}).strict();
|
|
5169
5195
|
async function parseAndVerifyResolvedWeightModelSelection(raw, input) {
|
|
@@ -5174,97 +5200,97 @@ async function parseAndVerifyResolvedWeightModelSelection(raw, input) {
|
|
|
5174
5200
|
throw new OpenPondProtocolError("weight_model_selection_mismatch", "The admitted Model differs from its exact learned patch and base.");
|
|
5175
5201
|
return value;
|
|
5176
5202
|
}
|
|
5177
|
-
var WeightModelInferenceReceiptContentSchema =
|
|
5178
|
-
schemaVersion:
|
|
5203
|
+
var WeightModelInferenceReceiptContentSchema = z44.object({
|
|
5204
|
+
schemaVersion: z44.literal("openpond.weightModelInferenceReceipt.v1"),
|
|
5179
5205
|
teamId: Id28,
|
|
5180
5206
|
requestId: Id28,
|
|
5181
5207
|
requestHash: Hash33,
|
|
5182
5208
|
selection: ResolvedWeightModelSelectionSchema,
|
|
5183
5209
|
poolId: Id28,
|
|
5184
|
-
routingBinding:
|
|
5210
|
+
routingBinding: z44.object({ id: Id28, revision: z44.number().int().positive() }).strict(),
|
|
5185
5211
|
runtimeHash: Hash33,
|
|
5186
|
-
workerImageDigest:
|
|
5187
|
-
engineGeneration:
|
|
5212
|
+
workerImageDigest: z44.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5213
|
+
engineGeneration: z44.number().int().positive(),
|
|
5188
5214
|
cacheNamespace: Hash33,
|
|
5189
|
-
completedAt:
|
|
5215
|
+
completedAt: z44.iso.datetime()
|
|
5190
5216
|
}).strict();
|
|
5191
5217
|
var WeightModelInferenceReceiptSchema = WeightModelInferenceReceiptContentSchema.extend({ contentHash: Hash33 });
|
|
5192
5218
|
async function parseAndVerifyWeightModelInferenceReceipt(raw, expected) {
|
|
5193
|
-
const value = WeightModelInferenceReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5219
|
+
const value = WeightModelInferenceReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5194
5220
|
await parseAndVerifyResolvedWeightModelSelection(value.selection, expected.version);
|
|
5195
|
-
if (
|
|
5221
|
+
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
5222
|
throw new OpenPondProtocolError("weight_model_inference_mismatch", "The completed inference differs from its admitted Model, runtime or cache.");
|
|
5197
5223
|
return value;
|
|
5198
5224
|
}
|
|
5199
5225
|
|
|
5200
5226
|
// src/alphaedit-model-serving.ts
|
|
5201
|
-
var Id29 =
|
|
5202
|
-
var Hash34 =
|
|
5203
|
-
var BindingRef2 =
|
|
5204
|
-
var AlphaEditModelServingQuerySchema =
|
|
5205
|
-
var AlphaEditModelServingControlRequestSchema =
|
|
5227
|
+
var Id29 = z45.string().trim().min(1).max(240);
|
|
5228
|
+
var Hash34 = z45.string().regex(/^[a-f0-9]{64}$/);
|
|
5229
|
+
var BindingRef2 = z45.object({ id: Id29, revision: z45.number().int().positive() }).strict();
|
|
5230
|
+
var AlphaEditModelServingQuerySchema = z45.object({ teamId: Id29, versionHash: Hash34 }).strict();
|
|
5231
|
+
var AlphaEditModelServingControlRequestSchema = z45.object({
|
|
5206
5232
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5207
|
-
schemaVersion:
|
|
5233
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControlRequest.v1"),
|
|
5208
5234
|
teamId: Id29,
|
|
5209
5235
|
operationId: Id29,
|
|
5210
5236
|
versionHash: Hash34,
|
|
5211
|
-
expectedRevision:
|
|
5212
|
-
action:
|
|
5213
|
-
idleTimeoutSeconds:
|
|
5237
|
+
expectedRevision: z45.number().int().nonnegative(),
|
|
5238
|
+
action: z45.enum(["activate", "stop"]),
|
|
5239
|
+
idleTimeoutSeconds: z45.number().int().min(60).max(3600)
|
|
5214
5240
|
}).strict();
|
|
5215
5241
|
var AlphaEditModelServingControlIntentSchema = AlphaEditModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id29 }).strict();
|
|
5216
|
-
var AlphaEditModelServingControlCommandSchema =
|
|
5217
|
-
var AlphaEditModelServingControlSchema =
|
|
5242
|
+
var AlphaEditModelServingControlCommandSchema = z45.object({ modelProjectId: Id29, request: AlphaEditModelServingControlRequestSchema }).strict();
|
|
5243
|
+
var AlphaEditModelServingControlSchema = z45.object({
|
|
5218
5244
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5219
|
-
schemaVersion:
|
|
5245
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControl.v1"),
|
|
5220
5246
|
teamId: Id29,
|
|
5221
5247
|
modelProjectId: Id29,
|
|
5222
5248
|
versionHash: Hash34,
|
|
5223
5249
|
actorId: Id29,
|
|
5224
5250
|
operationId: Id29,
|
|
5225
|
-
revision:
|
|
5226
|
-
desiredState:
|
|
5227
|
-
phase:
|
|
5228
|
-
capacityState:
|
|
5229
|
-
modelId:
|
|
5251
|
+
revision: z45.number().int().positive(),
|
|
5252
|
+
desiredState: z45.enum(["active", "stopped"]),
|
|
5253
|
+
phase: z45.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5254
|
+
capacityState: z45.enum(["pending", "shared", "retiring", "released"]),
|
|
5255
|
+
modelId: z45.string().trim().min(1).max(500),
|
|
5230
5256
|
poolId: Id29.nullable(),
|
|
5231
5257
|
binding: BindingRef2.nullable(),
|
|
5232
|
-
activeRequests:
|
|
5233
|
-
unsettledRequests:
|
|
5234
|
-
idleTimeoutSeconds:
|
|
5258
|
+
activeRequests: z45.number().int().nonnegative(),
|
|
5259
|
+
unsettledRequests: z45.number().int().nonnegative(),
|
|
5260
|
+
idleTimeoutSeconds: z45.number().int().min(60).max(3600),
|
|
5235
5261
|
failureCode: Id29.nullable(),
|
|
5236
|
-
updatedAt:
|
|
5262
|
+
updatedAt: z45.iso.datetime()
|
|
5237
5263
|
}).strict();
|
|
5238
|
-
var AlphaEditServingBindingSchema =
|
|
5264
|
+
var AlphaEditServingBindingSchema = z45.object({
|
|
5239
5265
|
id: Id29,
|
|
5240
|
-
revision:
|
|
5241
|
-
modelId:
|
|
5266
|
+
revision: z45.number().int().positive(),
|
|
5267
|
+
modelId: z45.string().trim().min(1).max(500),
|
|
5242
5268
|
poolId: Id29,
|
|
5243
5269
|
versionHash: Hash34
|
|
5244
5270
|
}).strict();
|
|
5245
|
-
var AlphaEditServingAvailabilitySchema =
|
|
5246
|
-
state:
|
|
5247
|
-
reason:
|
|
5271
|
+
var AlphaEditServingAvailabilitySchema = z45.object({
|
|
5272
|
+
state: z45.enum(["qualified", "unavailable"]),
|
|
5273
|
+
reason: z45.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5248
5274
|
runtimeHash: Hash34.nullable()
|
|
5249
5275
|
}).strict();
|
|
5250
|
-
var AlphaEditModelServingContentSchema =
|
|
5276
|
+
var AlphaEditModelServingContentSchema = z45.object({
|
|
5251
5277
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5252
|
-
schemaVersion:
|
|
5278
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServing.v1"),
|
|
5253
5279
|
teamId: Id29,
|
|
5254
5280
|
modelProjectId: Id29,
|
|
5255
|
-
observedAt:
|
|
5281
|
+
observedAt: z45.iso.datetime(),
|
|
5256
5282
|
version: AlphaEditModelVersionSchema,
|
|
5257
5283
|
availability: AlphaEditServingAvailabilitySchema,
|
|
5258
5284
|
control: AlphaEditModelServingControlSchema.nullable(),
|
|
5259
|
-
cleanup:
|
|
5260
|
-
pools:
|
|
5261
|
-
bindings:
|
|
5285
|
+
cleanup: z45.array(AlphaEditModelServingControlSchema).max(100),
|
|
5286
|
+
pools: z45.array(TrainingServingPoolSchema).max(100),
|
|
5287
|
+
bindings: z45.array(AlphaEditServingBindingSchema).max(100),
|
|
5262
5288
|
lastVerifiedInference: WeightModelInferenceReceiptSchema.nullable(),
|
|
5263
|
-
state:
|
|
5289
|
+
state: z45.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5264
5290
|
}).strict();
|
|
5265
5291
|
var AlphaEditModelServingSchema = AlphaEditModelServingContentSchema.extend({ contentHash: Hash34 });
|
|
5266
|
-
var AlphaEditModelServingControlReceiptContentSchema =
|
|
5267
|
-
schemaVersion:
|
|
5292
|
+
var AlphaEditModelServingControlReceiptContentSchema = z45.object({
|
|
5293
|
+
schemaVersion: z45.literal("openpond.alphaEditModelServingControlReceipt.v1"),
|
|
5268
5294
|
teamId: Id29,
|
|
5269
5295
|
modelProjectId: Id29,
|
|
5270
5296
|
actorId: Id29,
|
|
@@ -5287,24 +5313,24 @@ function alphaEditModelServingState(value) {
|
|
|
5287
5313
|
}
|
|
5288
5314
|
async function parseAndVerifyAlphaEditModelServingControl(raw, expected) {
|
|
5289
5315
|
const value = AlphaEditModelServingControlReceiptSchema.parse(raw), request = AlphaEditModelServingControlRequestSchema.parse(expected.request);
|
|
5290
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5316
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5291
5317
|
await parseAndVerifyAlphaEditModelVersion(value.version, {
|
|
5292
5318
|
teamId: request.teamId,
|
|
5293
5319
|
modelProjectId: expected.modelProjectId,
|
|
5294
5320
|
ownerUserId: value.actorId
|
|
5295
5321
|
});
|
|
5296
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5322
|
+
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
5323
|
throw new OpenPondProtocolError("alphaedit_serving_control_mismatch", "The serving receipt differs from the exact AlphaEdit Model or original control command.");
|
|
5298
5324
|
return value;
|
|
5299
5325
|
}
|
|
5300
5326
|
async function parseAndVerifyAlphaEditModelServing(raw, expected) {
|
|
5301
|
-
const value = AlphaEditModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5327
|
+
const value = AlphaEditModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5302
5328
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "alphaedit" }, value.control);
|
|
5303
5329
|
await parseAndVerifyAlphaEditModelVersion(value.version, expected);
|
|
5304
5330
|
function fail8() {
|
|
5305
5331
|
throw new OpenPondProtocolError("alphaedit_model_serving_mismatch", "The serving evidence differs from the exact AlphaEdit Model or retained resource custody.");
|
|
5306
5332
|
}
|
|
5307
|
-
if (
|
|
5333
|
+
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
5334
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5309
5335
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5310
5336
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl2(control3)) fail8();
|
|
@@ -5345,74 +5371,74 @@ function createAlphaEditModelServingClient(request) {
|
|
|
5345
5371
|
}
|
|
5346
5372
|
|
|
5347
5373
|
// 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 =
|
|
5374
|
+
import { z as z46 } from "zod";
|
|
5375
|
+
var Id30 = z46.string().trim().min(1).max(240);
|
|
5376
|
+
var Hash35 = z46.string().regex(/^[a-f0-9]{64}$/);
|
|
5377
|
+
var BindingRef3 = z46.object({ id: Id30, revision: z46.number().int().positive() }).strict();
|
|
5378
|
+
var NeuronTrainingModelServingQuerySchema = z46.object({ teamId: Id30, versionHash: Hash35 }).strict();
|
|
5379
|
+
var NeuronTrainingModelServingControlRequestSchema = z46.object({
|
|
5354
5380
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5355
|
-
schemaVersion:
|
|
5381
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControlRequest.v1"),
|
|
5356
5382
|
teamId: Id30,
|
|
5357
5383
|
operationId: Id30,
|
|
5358
5384
|
versionHash: Hash35,
|
|
5359
|
-
expectedRevision:
|
|
5360
|
-
action:
|
|
5361
|
-
idleTimeoutSeconds:
|
|
5385
|
+
expectedRevision: z46.number().int().nonnegative(),
|
|
5386
|
+
action: z46.enum(["activate", "stop"]),
|
|
5387
|
+
idleTimeoutSeconds: z46.number().int().min(60).max(3600)
|
|
5362
5388
|
}).strict();
|
|
5363
5389
|
var NeuronTrainingModelServingControlIntentSchema = NeuronTrainingModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id30 }).strict();
|
|
5364
|
-
var NeuronTrainingModelServingControlCommandSchema =
|
|
5365
|
-
var NeuronTrainingModelServingControlSchema =
|
|
5390
|
+
var NeuronTrainingModelServingControlCommandSchema = z46.object({ modelProjectId: Id30, request: NeuronTrainingModelServingControlRequestSchema }).strict();
|
|
5391
|
+
var NeuronTrainingModelServingControlSchema = z46.object({
|
|
5366
5392
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5367
|
-
schemaVersion:
|
|
5393
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControl.v1"),
|
|
5368
5394
|
teamId: Id30,
|
|
5369
5395
|
modelProjectId: Id30,
|
|
5370
5396
|
versionHash: Hash35,
|
|
5371
5397
|
actorId: Id30,
|
|
5372
5398
|
operationId: Id30,
|
|
5373
|
-
revision:
|
|
5374
|
-
desiredState:
|
|
5375
|
-
phase:
|
|
5376
|
-
capacityState:
|
|
5377
|
-
modelId:
|
|
5399
|
+
revision: z46.number().int().positive(),
|
|
5400
|
+
desiredState: z46.enum(["active", "stopped"]),
|
|
5401
|
+
phase: z46.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5402
|
+
capacityState: z46.enum(["pending", "shared", "retiring", "released"]),
|
|
5403
|
+
modelId: z46.string().trim().min(1).max(500),
|
|
5378
5404
|
poolId: Id30.nullable(),
|
|
5379
5405
|
binding: BindingRef3.nullable(),
|
|
5380
|
-
activeRequests:
|
|
5381
|
-
unsettledRequests:
|
|
5382
|
-
idleTimeoutSeconds:
|
|
5406
|
+
activeRequests: z46.number().int().nonnegative(),
|
|
5407
|
+
unsettledRequests: z46.number().int().nonnegative(),
|
|
5408
|
+
idleTimeoutSeconds: z46.number().int().min(60).max(3600),
|
|
5383
5409
|
failureCode: Id30.nullable(),
|
|
5384
|
-
updatedAt:
|
|
5410
|
+
updatedAt: z46.iso.datetime()
|
|
5385
5411
|
}).strict();
|
|
5386
|
-
var NeuronTrainingServingBindingSchema =
|
|
5412
|
+
var NeuronTrainingServingBindingSchema = z46.object({
|
|
5387
5413
|
id: Id30,
|
|
5388
|
-
revision:
|
|
5389
|
-
modelId:
|
|
5414
|
+
revision: z46.number().int().positive(),
|
|
5415
|
+
modelId: z46.string().trim().min(1).max(500),
|
|
5390
5416
|
poolId: Id30,
|
|
5391
5417
|
versionHash: Hash35
|
|
5392
5418
|
}).strict();
|
|
5393
|
-
var NeuronTrainingServingAvailabilitySchema =
|
|
5394
|
-
state:
|
|
5395
|
-
reason:
|
|
5419
|
+
var NeuronTrainingServingAvailabilitySchema = z46.object({
|
|
5420
|
+
state: z46.enum(["qualified", "unavailable"]),
|
|
5421
|
+
reason: z46.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5396
5422
|
runtimeHash: Hash35.nullable()
|
|
5397
5423
|
}).strict();
|
|
5398
|
-
var NeuronTrainingModelServingContentSchema =
|
|
5424
|
+
var NeuronTrainingModelServingContentSchema = z46.object({
|
|
5399
5425
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5400
|
-
schemaVersion:
|
|
5426
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServing.v1"),
|
|
5401
5427
|
teamId: Id30,
|
|
5402
5428
|
modelProjectId: Id30,
|
|
5403
|
-
observedAt:
|
|
5429
|
+
observedAt: z46.iso.datetime(),
|
|
5404
5430
|
version: NeuronTrainingModelVersionSchema,
|
|
5405
5431
|
availability: NeuronTrainingServingAvailabilitySchema,
|
|
5406
5432
|
control: NeuronTrainingModelServingControlSchema.nullable(),
|
|
5407
|
-
cleanup:
|
|
5408
|
-
pools:
|
|
5409
|
-
bindings:
|
|
5433
|
+
cleanup: z46.array(NeuronTrainingModelServingControlSchema).max(100),
|
|
5434
|
+
pools: z46.array(TrainingServingPoolSchema).max(100),
|
|
5435
|
+
bindings: z46.array(NeuronTrainingServingBindingSchema).max(100),
|
|
5410
5436
|
lastVerifiedInference: WeightModelInferenceReceiptSchema.nullable(),
|
|
5411
|
-
state:
|
|
5437
|
+
state: z46.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5412
5438
|
}).strict();
|
|
5413
5439
|
var NeuronTrainingModelServingSchema = NeuronTrainingModelServingContentSchema.extend({ contentHash: Hash35 });
|
|
5414
|
-
var NeuronTrainingModelServingControlReceiptContentSchema =
|
|
5415
|
-
schemaVersion:
|
|
5440
|
+
var NeuronTrainingModelServingControlReceiptContentSchema = z46.object({
|
|
5441
|
+
schemaVersion: z46.literal("openpond.neuronTrainingModelServingControlReceipt.v1"),
|
|
5416
5442
|
teamId: Id30,
|
|
5417
5443
|
modelProjectId: Id30,
|
|
5418
5444
|
actorId: Id30,
|
|
@@ -5435,24 +5461,24 @@ function neuronTrainingModelServingState(value) {
|
|
|
5435
5461
|
}
|
|
5436
5462
|
async function parseAndVerifyNeuronTrainingModelServingControl(raw, expected) {
|
|
5437
5463
|
const value = NeuronTrainingModelServingControlReceiptSchema.parse(raw), request = NeuronTrainingModelServingControlRequestSchema.parse(expected.request);
|
|
5438
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5464
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5439
5465
|
await parseAndVerifyNeuronTrainingModelVersion(value.version, {
|
|
5440
5466
|
teamId: request.teamId,
|
|
5441
5467
|
modelProjectId: expected.modelProjectId,
|
|
5442
5468
|
ownerUserId: value.actorId
|
|
5443
5469
|
});
|
|
5444
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5470
|
+
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
5471
|
throw new OpenPondProtocolError("neuron_training_serving_control_mismatch", "The serving receipt differs from the exact neuron-training Model or original control command.");
|
|
5446
5472
|
return value;
|
|
5447
5473
|
}
|
|
5448
5474
|
async function parseAndVerifyNeuronTrainingModelServing(raw, expected) {
|
|
5449
|
-
const value = NeuronTrainingModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5475
|
+
const value = NeuronTrainingModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5450
5476
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "selective_neuron_training" }, value.control);
|
|
5451
5477
|
await parseAndVerifyNeuronTrainingModelVersion(value.version, expected);
|
|
5452
5478
|
function fail8() {
|
|
5453
5479
|
throw new OpenPondProtocolError("neuron_training_model_serving_mismatch", "The serving evidence differs from the exact neuron-training Model or retained resource custody.");
|
|
5454
5480
|
}
|
|
5455
|
-
if (
|
|
5481
|
+
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
5482
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5457
5483
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5458
5484
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl3(control3)) fail8();
|
|
@@ -5493,20 +5519,20 @@ function createNeuronTrainingModelServingClient(request) {
|
|
|
5493
5519
|
}
|
|
5494
5520
|
|
|
5495
5521
|
// src/decision-model-scoring.ts
|
|
5496
|
-
import { z as
|
|
5522
|
+
import { z as z47 } from "zod";
|
|
5497
5523
|
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:
|
|
5524
|
+
var Id31 = z47.string().trim().min(1).max(240);
|
|
5525
|
+
var Hash36 = z47.string().regex(/^[a-f0-9]{64}$/);
|
|
5526
|
+
var Binding = z47.object({ id: Id31, revision: z47.number().int().positive() }).strict();
|
|
5527
|
+
var SavedDecisionModelSelectionSchema = z47.object({ modelProjectId: Id31, versionHash: Hash36 }).strict();
|
|
5528
|
+
var ResolvedDecisionSelectionSchema = z47.object({
|
|
5529
|
+
schemaVersion: z47.literal("openpond.resolvedDecisionSelection.v1"),
|
|
5504
5530
|
savedModel: SavedDecisionModelSelectionSchema,
|
|
5505
5531
|
modelHash: Hash36,
|
|
5506
|
-
artifact:
|
|
5532
|
+
artifact: z47.object({ id: Id31, contentHash: Hash36, payloadSha256: Hash36 }).strict()
|
|
5507
5533
|
}).strict();
|
|
5508
|
-
var DecisionModelScoreRequestSchema =
|
|
5509
|
-
schemaVersion:
|
|
5534
|
+
var DecisionModelScoreRequestSchema = z47.object({
|
|
5535
|
+
schemaVersion: z47.literal("openpond.decisionModelScoreRequest.v1"),
|
|
5510
5536
|
teamId: Id31,
|
|
5511
5537
|
requestId: Id31,
|
|
5512
5538
|
versionHash: Hash36,
|
|
@@ -5536,8 +5562,8 @@ async function parseAndVerifyResolvedDecisionSelection(raw, version) {
|
|
|
5536
5562
|
throw new OpenPondProtocolError("decision_selection_mismatch", "The scorer selected a different exact decision Model or adapter.");
|
|
5537
5563
|
return value;
|
|
5538
5564
|
}
|
|
5539
|
-
var DecisionModelScoreReceiptContentSchema =
|
|
5540
|
-
schemaVersion:
|
|
5565
|
+
var DecisionModelScoreReceiptContentSchema = z47.object({
|
|
5566
|
+
schemaVersion: z47.literal("openpond.decisionModelScoreReceipt.v1"),
|
|
5541
5567
|
teamId: Id31,
|
|
5542
5568
|
actorId: Id31,
|
|
5543
5569
|
modelProjectId: Id31,
|
|
@@ -5549,17 +5575,17 @@ var DecisionModelScoreReceiptContentSchema = z46.object({
|
|
|
5549
5575
|
poolId: Id31,
|
|
5550
5576
|
routingBinding: Binding,
|
|
5551
5577
|
runtimeHash: Hash36,
|
|
5552
|
-
workerImageDigest:
|
|
5553
|
-
engineGeneration:
|
|
5578
|
+
workerImageDigest: z47.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5579
|
+
engineGeneration: z47.number().int().positive(),
|
|
5554
5580
|
cacheNamespace: Hash36,
|
|
5555
|
-
cleanupComplete:
|
|
5556
|
-
completedAt:
|
|
5581
|
+
cleanupComplete: z47.literal(true),
|
|
5582
|
+
completedAt: z47.iso.datetime()
|
|
5557
5583
|
}).strict();
|
|
5558
5584
|
var DecisionModelScoreReceiptSchema = DecisionModelScoreReceiptContentSchema.extend({ contentHash: Hash36 });
|
|
5559
5585
|
async function parseAndVerifyDecisionModelScoreReceipt(raw, expected) {
|
|
5560
5586
|
assertBoundedTaskJson8(raw, 1048576);
|
|
5561
5587
|
const request = parseDecisionModelScoreRequest(expected.request);
|
|
5562
|
-
const value = DecisionModelScoreReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
5588
|
+
const value = DecisionModelScoreReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5563
5589
|
const version = await parseAndVerifyDecisionModelVersion(value.version, {
|
|
5564
5590
|
teamId: request.teamId,
|
|
5565
5591
|
modelProjectId: expected.modelProjectId,
|
|
@@ -5578,7 +5604,7 @@ async function parseAndVerifyDecisionModelScoreReceipt(raw, expected) {
|
|
|
5578
5604
|
function fail8() {
|
|
5579
5605
|
throw new OpenPondProtocolError("decision_model_score_mismatch", "The completed score differs from the exact Model, original request or admitted runtime.");
|
|
5580
5606
|
}
|
|
5581
|
-
if (
|
|
5607
|
+
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
5608
|
const admission = expected.admission;
|
|
5583
5609
|
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
5610
|
return value;
|
|
@@ -5597,74 +5623,74 @@ function createDecisionModelScoringClient(request) {
|
|
|
5597
5623
|
}
|
|
5598
5624
|
|
|
5599
5625
|
// src/decision-model-serving.ts
|
|
5600
|
-
import { z as
|
|
5601
|
-
var Id32 =
|
|
5602
|
-
var Hash37 =
|
|
5603
|
-
var BindingRef4 =
|
|
5604
|
-
var DecisionModelServingQuerySchema =
|
|
5605
|
-
var DecisionModelServingControlRequestSchema =
|
|
5626
|
+
import { z as z48 } from "zod";
|
|
5627
|
+
var Id32 = z48.string().trim().min(1).max(240);
|
|
5628
|
+
var Hash37 = z48.string().regex(/^[a-f0-9]{64}$/);
|
|
5629
|
+
var BindingRef4 = z48.object({ id: Id32, revision: z48.number().int().positive() }).strict();
|
|
5630
|
+
var DecisionModelServingQuerySchema = z48.object({ teamId: Id32, versionHash: Hash37 }).strict();
|
|
5631
|
+
var DecisionModelServingControlRequestSchema = z48.object({
|
|
5606
5632
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
5607
|
-
schemaVersion:
|
|
5633
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControlRequest.v1"),
|
|
5608
5634
|
teamId: Id32,
|
|
5609
5635
|
operationId: Id32,
|
|
5610
5636
|
versionHash: Hash37,
|
|
5611
|
-
expectedRevision:
|
|
5612
|
-
action:
|
|
5613
|
-
idleTimeoutSeconds:
|
|
5637
|
+
expectedRevision: z48.number().int().nonnegative(),
|
|
5638
|
+
action: z48.enum(["activate", "stop"]),
|
|
5639
|
+
idleTimeoutSeconds: z48.number().int().min(60).max(3600)
|
|
5614
5640
|
}).strict();
|
|
5615
5641
|
var DecisionModelServingControlIntentSchema = DecisionModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id32 }).strict();
|
|
5616
|
-
var DecisionModelServingControlCommandSchema =
|
|
5617
|
-
var DecisionModelServingControlSchema =
|
|
5642
|
+
var DecisionModelServingControlCommandSchema = z48.object({ modelProjectId: Id32, request: DecisionModelServingControlRequestSchema }).strict();
|
|
5643
|
+
var DecisionModelServingControlSchema = z48.object({
|
|
5618
5644
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
5619
|
-
schemaVersion:
|
|
5645
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControl.v1"),
|
|
5620
5646
|
teamId: Id32,
|
|
5621
5647
|
modelProjectId: Id32,
|
|
5622
5648
|
versionHash: Hash37,
|
|
5623
5649
|
actorId: Id32,
|
|
5624
5650
|
operationId: Id32,
|
|
5625
|
-
revision:
|
|
5626
|
-
desiredState:
|
|
5627
|
-
phase:
|
|
5628
|
-
capacityState:
|
|
5629
|
-
modelId:
|
|
5651
|
+
revision: z48.number().int().positive(),
|
|
5652
|
+
desiredState: z48.enum(["active", "stopped"]),
|
|
5653
|
+
phase: z48.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
5654
|
+
capacityState: z48.enum(["pending", "shared", "retiring", "released"]),
|
|
5655
|
+
modelId: z48.string().trim().min(1).max(500),
|
|
5630
5656
|
poolId: Id32.nullable(),
|
|
5631
5657
|
binding: BindingRef4.nullable(),
|
|
5632
|
-
activeRequests:
|
|
5633
|
-
unsettledRequests:
|
|
5634
|
-
idleTimeoutSeconds:
|
|
5658
|
+
activeRequests: z48.number().int().nonnegative(),
|
|
5659
|
+
unsettledRequests: z48.number().int().nonnegative(),
|
|
5660
|
+
idleTimeoutSeconds: z48.number().int().min(60).max(3600),
|
|
5635
5661
|
failureCode: Id32.nullable(),
|
|
5636
|
-
updatedAt:
|
|
5662
|
+
updatedAt: z48.iso.datetime()
|
|
5637
5663
|
}).strict();
|
|
5638
|
-
var DecisionServingBindingSchema =
|
|
5664
|
+
var DecisionServingBindingSchema = z48.object({
|
|
5639
5665
|
id: Id32,
|
|
5640
|
-
revision:
|
|
5641
|
-
modelId:
|
|
5666
|
+
revision: z48.number().int().positive(),
|
|
5667
|
+
modelId: z48.string().trim().min(1).max(500),
|
|
5642
5668
|
poolId: Id32,
|
|
5643
5669
|
versionHash: Hash37
|
|
5644
5670
|
}).strict();
|
|
5645
|
-
var DecisionServingAvailabilitySchema =
|
|
5646
|
-
state:
|
|
5647
|
-
reason:
|
|
5671
|
+
var DecisionServingAvailabilitySchema = z48.object({
|
|
5672
|
+
state: z48.enum(["qualified", "unavailable"]),
|
|
5673
|
+
reason: z48.enum(["qualified", "runtime_unavailable", "artifact_unavailable", "model_mismatch"]),
|
|
5648
5674
|
runtimeHash: Hash37.nullable()
|
|
5649
5675
|
}).strict();
|
|
5650
|
-
var DecisionModelServingContentSchema =
|
|
5676
|
+
var DecisionModelServingContentSchema = z48.object({
|
|
5651
5677
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
5652
|
-
schemaVersion:
|
|
5678
|
+
schemaVersion: z48.literal("openpond.decisionModelServing.v1"),
|
|
5653
5679
|
teamId: Id32,
|
|
5654
5680
|
modelProjectId: Id32,
|
|
5655
|
-
observedAt:
|
|
5681
|
+
observedAt: z48.iso.datetime(),
|
|
5656
5682
|
version: DecisionModelVersionSchema,
|
|
5657
5683
|
availability: DecisionServingAvailabilitySchema,
|
|
5658
5684
|
control: DecisionModelServingControlSchema.nullable(),
|
|
5659
|
-
cleanup:
|
|
5660
|
-
pools:
|
|
5661
|
-
bindings:
|
|
5685
|
+
cleanup: z48.array(DecisionModelServingControlSchema).max(100),
|
|
5686
|
+
pools: z48.array(TrainingServingPoolSchema).max(100),
|
|
5687
|
+
bindings: z48.array(DecisionServingBindingSchema).max(100),
|
|
5662
5688
|
lastVerifiedScore: DecisionModelScoreReceiptSchema.nullable(),
|
|
5663
|
-
state:
|
|
5689
|
+
state: z48.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
5664
5690
|
}).strict();
|
|
5665
5691
|
var DecisionModelServingSchema = DecisionModelServingContentSchema.extend({ contentHash: Hash37 });
|
|
5666
|
-
var DecisionModelServingControlReceiptContentSchema =
|
|
5667
|
-
schemaVersion:
|
|
5692
|
+
var DecisionModelServingControlReceiptContentSchema = z48.object({
|
|
5693
|
+
schemaVersion: z48.literal("openpond.decisionModelServingControlReceipt.v1"),
|
|
5668
5694
|
teamId: Id32,
|
|
5669
5695
|
modelProjectId: Id32,
|
|
5670
5696
|
actorId: Id32,
|
|
@@ -5687,25 +5713,25 @@ function decisionModelServingState(value) {
|
|
|
5687
5713
|
}
|
|
5688
5714
|
async function parseAndVerifyDecisionModelServingControl(raw, expected) {
|
|
5689
5715
|
const value = DecisionModelServingControlReceiptSchema.parse(raw), request = DecisionModelServingControlRequestSchema.parse(expected.request);
|
|
5690
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
5716
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
5691
5717
|
await parseAndVerifyDecisionModelVersion(value.version, {
|
|
5692
5718
|
teamId: request.teamId,
|
|
5693
5719
|
modelProjectId: expected.modelProjectId,
|
|
5694
5720
|
ownerUserId: value.actorId,
|
|
5695
5721
|
versionHash: request.versionHash
|
|
5696
5722
|
});
|
|
5697
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
5723
|
+
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
5724
|
throw new OpenPondProtocolError("decision_serving_control_mismatch", "The serving receipt differs from the exact decision Model or original control command.");
|
|
5699
5725
|
return value;
|
|
5700
5726
|
}
|
|
5701
5727
|
async function parseAndVerifyDecisionModelServing(raw, expected) {
|
|
5702
|
-
const value = DecisionModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
5728
|
+
const value = DecisionModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
5703
5729
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "decision" }, value.control);
|
|
5704
5730
|
await parseAndVerifyDecisionModelVersion(value.version, expected);
|
|
5705
5731
|
function fail8() {
|
|
5706
5732
|
throw new OpenPondProtocolError("decision_model_serving_mismatch", "The serving evidence differs from the exact decision Model or retained resource custody.");
|
|
5707
5733
|
}
|
|
5708
|
-
if (
|
|
5734
|
+
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
5735
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
5710
5736
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []])
|
|
5711
5737
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl4(control3)) fail8();
|
|
@@ -5856,30 +5882,30 @@ async function engramFormFromModelVersion(form, raw, expected = {}) {
|
|
|
5856
5882
|
}
|
|
5857
5883
|
|
|
5858
5884
|
// src/training-executions.ts
|
|
5859
|
-
import { z as
|
|
5860
|
-
var Id33 =
|
|
5861
|
-
var TrainingExecutionSummarySchema =
|
|
5862
|
-
schemaVersion:
|
|
5863
|
-
job:
|
|
5864
|
-
name:
|
|
5865
|
-
method:
|
|
5866
|
-
model:
|
|
5885
|
+
import { z as z49 } from "zod";
|
|
5886
|
+
var Id33 = z49.string().trim().min(1).max(500);
|
|
5887
|
+
var TrainingExecutionSummarySchema = z49.object({
|
|
5888
|
+
schemaVersion: z49.literal("openpond.trainingExecutionSummary.v1"),
|
|
5889
|
+
job: z49.lazy(() => TrainingJobSchema),
|
|
5890
|
+
name: z49.string().min(1).max(500),
|
|
5891
|
+
method: z49.enum(["sft", "grpo", "reward_model_train"]).nullable(),
|
|
5892
|
+
model: z49.object({ modelId: Id33, revision: Id33.nullable() }).strict().nullable(),
|
|
5867
5893
|
dataset: ModelProjectVersionedRefSchema.nullable(),
|
|
5868
|
-
startedAt:
|
|
5894
|
+
startedAt: z49.iso.datetime().nullable()
|
|
5869
5895
|
}).strict();
|
|
5870
|
-
var TrainingExecutionListQuerySchema =
|
|
5896
|
+
var TrainingExecutionListQuerySchema = z49.object({
|
|
5871
5897
|
projectId: Id33.optional(),
|
|
5872
|
-
datasetHash:
|
|
5873
|
-
search:
|
|
5874
|
-
cursor:
|
|
5875
|
-
limit:
|
|
5898
|
+
datasetHash: z49.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
5899
|
+
search: z49.string().trim().max(1e3).optional(),
|
|
5900
|
+
cursor: z49.string().trim().min(1).max(2e3).optional(),
|
|
5901
|
+
limit: z49.number().int().min(1).max(100).default(30)
|
|
5876
5902
|
}).strict();
|
|
5877
|
-
var TrainingExecutionPageSchema =
|
|
5878
|
-
schemaVersion:
|
|
5903
|
+
var TrainingExecutionPageSchema = z49.object({
|
|
5904
|
+
schemaVersion: z49.literal("openpond.trainingExecutionPage.v1"),
|
|
5879
5905
|
teamId: Id33,
|
|
5880
5906
|
projectId: Id33.nullable(),
|
|
5881
|
-
items:
|
|
5882
|
-
nextCursor:
|
|
5907
|
+
items: z49.array(TrainingExecutionSummarySchema).max(100),
|
|
5908
|
+
nextCursor: z49.string().trim().min(1).max(2e3).nullable()
|
|
5883
5909
|
}).strict();
|
|
5884
5910
|
function createTrainingExecutionClient(request) {
|
|
5885
5911
|
return {
|
|
@@ -5903,10 +5929,10 @@ function createTrainingExecutionClient(request) {
|
|
|
5903
5929
|
}
|
|
5904
5930
|
|
|
5905
5931
|
// src/training-acceptance.ts
|
|
5906
|
-
import { z as
|
|
5932
|
+
import { z as z50 } from "zod";
|
|
5907
5933
|
import { assertAcceptanceGroupSnapshot, AcceptanceGroupSnapshotSchema } from "@openpond/evals/learning";
|
|
5908
|
-
var Id34 =
|
|
5909
|
-
var TrainingAcceptanceGroupReferenceSchema = ModelProjectImmutableRefSchema.extend({ revision:
|
|
5934
|
+
var Id34 = z50.string().trim().min(1).max(240);
|
|
5935
|
+
var TrainingAcceptanceGroupReferenceSchema = ModelProjectImmutableRefSchema.extend({ revision: z50.number().int().positive() }).strict();
|
|
5910
5936
|
var TrainingAcceptanceGroupSummarySchema = TrainingAcceptanceGroupReferenceSchema.extend({
|
|
5911
5937
|
teamId: Id34,
|
|
5912
5938
|
jobId: Id34,
|
|
@@ -5914,18 +5940,18 @@ var TrainingAcceptanceGroupSummarySchema = TrainingAcceptanceGroupReferenceSchem
|
|
|
5914
5940
|
baseline: ModelProjectImmutableRefSchema,
|
|
5915
5941
|
candidate: ModelProjectImmutableRefSchema,
|
|
5916
5942
|
state: AcceptanceGroupSnapshotSchema.shape.state,
|
|
5917
|
-
updatedAt:
|
|
5943
|
+
updatedAt: z50.string().datetime()
|
|
5918
5944
|
}).strict();
|
|
5919
|
-
var TrainingAcceptanceGroupPageSchema =
|
|
5920
|
-
schemaVersion:
|
|
5945
|
+
var TrainingAcceptanceGroupPageSchema = z50.object({
|
|
5946
|
+
schemaVersion: z50.literal("openpond.trainingAcceptanceGroupPage.v1"),
|
|
5921
5947
|
teamId: Id34,
|
|
5922
5948
|
jobId: Id34,
|
|
5923
|
-
groups:
|
|
5949
|
+
groups: z50.array(TrainingAcceptanceGroupSummarySchema).max(100),
|
|
5924
5950
|
nextCursor: Id34.nullable()
|
|
5925
5951
|
}).strict();
|
|
5926
|
-
var TrainingAcceptanceGroupQuerySchema =
|
|
5952
|
+
var TrainingAcceptanceGroupQuerySchema = z50.object({
|
|
5927
5953
|
cursor: Id34.optional(),
|
|
5928
|
-
limit:
|
|
5954
|
+
limit: z50.number().int().min(1).max(100).default(25)
|
|
5929
5955
|
}).strict();
|
|
5930
5956
|
function createTrainingAcceptanceClient(request) {
|
|
5931
5957
|
const route = (target) => {
|
|
@@ -5955,21 +5981,110 @@ function createTrainingAcceptanceClient(request) {
|
|
|
5955
5981
|
}
|
|
5956
5982
|
|
|
5957
5983
|
// src/training.ts
|
|
5958
|
-
import { z as
|
|
5984
|
+
import { z as z67 } from "zod";
|
|
5959
5985
|
|
|
5960
|
-
// src/training-
|
|
5986
|
+
// src/training-experiment-learning.ts
|
|
5961
5987
|
import { z as z51 } from "zod";
|
|
5988
|
+
import { LearningRevisionRefSchema as LearningRevisionRefSchema2 } from "@openpond/evals/learning";
|
|
5989
|
+
var TrainingExperimentLearningRequestSchema = z51.object({
|
|
5990
|
+
schemaVersion: z51.literal("openpond.trainingExperimentLearning.v1"),
|
|
5991
|
+
teamId: z51.string().min(1).max(191),
|
|
5992
|
+
projectId: z51.string().min(1).max(191).nullable(),
|
|
5993
|
+
draftId: z51.string().min(1).max(191),
|
|
5994
|
+
form: TrainingExperimentFormDraftSchema.omit({ learningConfiguration: true }),
|
|
5995
|
+
expectedConfiguration: TrainingPreparationRequestSchema.shape.configuration.optional(),
|
|
5996
|
+
expectedPolicy: LearningRevisionRefSchema2.optional()
|
|
5997
|
+
}).strict();
|
|
5998
|
+
var TrainingExperimentLearningReceiptSchema = z51.object({
|
|
5999
|
+
schemaVersion: z51.literal("openpond.trainingExperimentLearningReceipt.v1"),
|
|
6000
|
+
inputHash: z51.string().regex(/^[a-f0-9]{64}$/),
|
|
6001
|
+
configuration: HostedModelProjectSummarySchema,
|
|
6002
|
+
policy: LearningRevisionRefSchema2
|
|
6003
|
+
}).strict();
|
|
6004
|
+
function trainingExperimentLearningRequest(input) {
|
|
6005
|
+
const { learningConfiguration, ...form } = input.form;
|
|
6006
|
+
const saved = learningConfiguration?.configuration;
|
|
6007
|
+
return TrainingExperimentLearningRequestSchema.parse({
|
|
6008
|
+
schemaVersion: "openpond.trainingExperimentLearning.v1",
|
|
6009
|
+
...input,
|
|
6010
|
+
form,
|
|
6011
|
+
...saved ? { expectedConfiguration: { id: saved.id, expectedRevision: saved.revision, expectedEtag: saved.etag }, expectedPolicy: learningConfiguration.policy } : {}
|
|
6012
|
+
});
|
|
6013
|
+
}
|
|
6014
|
+
async function trainingExperimentLearningInputHash(input) {
|
|
6015
|
+
const value = TrainingExperimentLearningRequestSchema.parse(input);
|
|
6016
|
+
const { baseModel, recipe, batch, evaluation, validationSplit, learningIntent } = value.form;
|
|
6017
|
+
return canonicalSha256({
|
|
6018
|
+
teamId: value.teamId,
|
|
6019
|
+
projectId: value.projectId,
|
|
6020
|
+
draftId: value.draftId,
|
|
6021
|
+
baseModel,
|
|
6022
|
+
recipe,
|
|
6023
|
+
batch,
|
|
6024
|
+
evaluation,
|
|
6025
|
+
validationSplit,
|
|
6026
|
+
learningIntent
|
|
6027
|
+
});
|
|
6028
|
+
}
|
|
6029
|
+
async function trainingExperimentTrainingInputHash(form) {
|
|
6030
|
+
const { baseModel, recipe, batch, evaluation, validationSplit } = form;
|
|
6031
|
+
return canonicalSha256({ baseModel, recipe, batch, evaluation, validationSplit });
|
|
6032
|
+
}
|
|
6033
|
+
async function trainingExperimentSavedConfiguration(form) {
|
|
6034
|
+
const saved = form.learningConfiguration;
|
|
6035
|
+
if (saved && saved.trainingInputHash !== await trainingExperimentTrainingInputHash(form))
|
|
6036
|
+
throw new Error("Save the changed training inputs before preparing this Model, or restore its accepted settings.");
|
|
6037
|
+
return saved;
|
|
6038
|
+
}
|
|
6039
|
+
function trainingExperimentInitialLearning(input) {
|
|
6040
|
+
const value = input.form.learningIntent;
|
|
6041
|
+
if (!value || !value.enabled && !input.expectedPolicy) throw new Error("Enable continual learning before saving its first policy.");
|
|
6042
|
+
return ModelInitialLearningSchema.parse({
|
|
6043
|
+
mode: value.mode,
|
|
6044
|
+
minimumTasks: Number(value.minimumTasks),
|
|
6045
|
+
localTime: value.localTime,
|
|
6046
|
+
timeZone: value.timeZone,
|
|
6047
|
+
maximumSpendUsd: Number(value.maximumSpendUsd),
|
|
6048
|
+
maximumDailySpendUsd: Number(value.maximumDailySpendUsd)
|
|
6049
|
+
});
|
|
6050
|
+
}
|
|
6051
|
+
function trainingExperimentLearningSettings(form) {
|
|
6052
|
+
return ModelProjectTrainingSetupSchema.parse({
|
|
6053
|
+
method: form.recipe.method,
|
|
6054
|
+
baseModel: form.baseModel,
|
|
6055
|
+
recipe: { ...form.recipe, dataset: { ...form.recipe.dataset && typeof form.recipe.dataset === "object" ? form.recipe.dataset : {}, validationSplit: form.validationSplit } },
|
|
6056
|
+
evaluationTasksetRef: form.evaluation,
|
|
6057
|
+
managedRolloutPlacement: "remote"
|
|
6058
|
+
});
|
|
6059
|
+
}
|
|
6060
|
+
function createTrainingExperimentLearningClient(request) {
|
|
6061
|
+
return {
|
|
6062
|
+
async saveExperimentLearning(input) {
|
|
6063
|
+
const parsed = TrainingExperimentLearningRequestSchema.parse(input);
|
|
6064
|
+
const result = TrainingExperimentLearningReceiptSchema.parse(await request("/v1/training/preparations/from-draft/learning", { method: "POST", body: JSON.stringify(parsed) }));
|
|
6065
|
+
const pausing = parsed.form.learningIntent?.enabled === false && Boolean(parsed.expectedConfiguration && parsed.expectedPolicy);
|
|
6066
|
+
const expected = parsed.expectedConfiguration;
|
|
6067
|
+
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();
|
|
6068
|
+
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))
|
|
6069
|
+
throw new OpenPondProtocolError("training_experiment_learning_mismatch", "The saved learning policy does not match its authored inputs.");
|
|
6070
|
+
return result;
|
|
6071
|
+
}
|
|
6072
|
+
};
|
|
6073
|
+
}
|
|
6074
|
+
|
|
6075
|
+
// src/training-estimates.ts
|
|
6076
|
+
import { z as z53 } from "zod";
|
|
5962
6077
|
|
|
5963
6078
|
// src/training-estimate-workload.ts
|
|
5964
|
-
import { z as
|
|
6079
|
+
import { z as z52 } from "zod";
|
|
5965
6080
|
var Hash38 = ModelProjectImmutableRefSchema.shape.contentHash;
|
|
5966
|
-
var Count =
|
|
5967
|
-
var Reason =
|
|
5968
|
-
var Coverage =
|
|
5969
|
-
var Identity =
|
|
6081
|
+
var Count = z52.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6082
|
+
var Reason = z52.string().trim().min(1).max(1e3);
|
|
6083
|
+
var Coverage = z52.enum(["complete", "bounded", "unavailable"]);
|
|
6084
|
+
var Identity = z52.object({
|
|
5970
6085
|
baseModel: ModelProjectBaseModelSchema.extend({
|
|
5971
|
-
revision:
|
|
5972
|
-
tokenizerRevision:
|
|
6086
|
+
revision: z52.string().trim().min(1).max(256),
|
|
6087
|
+
tokenizerRevision: z52.string().trim().min(1).max(256),
|
|
5973
6088
|
chatTemplateHash: Hash38
|
|
5974
6089
|
}).strict(),
|
|
5975
6090
|
/** Hash the full verified recipe, including optimizer and sampling settings. */
|
|
@@ -5978,17 +6093,17 @@ var Identity = z50.object({
|
|
|
5978
6093
|
harnessRelease: ModelProjectImmutableRefSchema,
|
|
5979
6094
|
dataset: ModelProjectImmutableRefSchema,
|
|
5980
6095
|
evaluationDataset: ModelProjectImmutableRefSchema.nullable(),
|
|
5981
|
-
evidenceSets:
|
|
6096
|
+
evidenceSets: z52.array(ModelProjectImmutableRefSchema).max(1e4)
|
|
5982
6097
|
}).strict();
|
|
5983
|
-
var Preprocessing =
|
|
5984
|
-
version:
|
|
6098
|
+
var Preprocessing = z52.object({
|
|
6099
|
+
version: z52.string().trim().min(1).max(191),
|
|
5985
6100
|
/** Includes policy framing, template invocation, admission and mask code. */
|
|
5986
6101
|
implementationHash: Hash38,
|
|
5987
6102
|
/** Hash of the verified tokenizer file inventory (paths, sizes and hashes). */
|
|
5988
6103
|
tokenizerAssetsHash: Hash38,
|
|
5989
|
-
enableThinking:
|
|
6104
|
+
enableThinking: z52.literal(false)
|
|
5990
6105
|
}).strict();
|
|
5991
|
-
var SftTokens =
|
|
6106
|
+
var SftTokens = z52.object({
|
|
5992
6107
|
promptTokens: Count,
|
|
5993
6108
|
retainedPromptTokens: Count,
|
|
5994
6109
|
/** Includes the final assistant terminal marker; prompt labels are masked. */
|
|
@@ -6000,7 +6115,7 @@ var SftTokens = z50.object({
|
|
|
6000
6115
|
context.addIssue({ code: "custom", message: "SFT tokens must preserve the target and partition the retained input" });
|
|
6001
6116
|
}
|
|
6002
6117
|
});
|
|
6003
|
-
var Population =
|
|
6118
|
+
var Population = z52.object({
|
|
6004
6119
|
coverage: Coverage,
|
|
6005
6120
|
total: Count.nullable(),
|
|
6006
6121
|
counted: Count,
|
|
@@ -6022,7 +6137,7 @@ function verifyPopulation(value, context) {
|
|
|
6022
6137
|
context.addIssue({ code: "custom", path: ["reason"], message: "Bounded coverage must explain its limit" });
|
|
6023
6138
|
}
|
|
6024
6139
|
}
|
|
6025
|
-
var PromptPopulation = Population.extend({ totals:
|
|
6140
|
+
var PromptPopulation = Population.extend({ totals: z52.object({ promptTokens: Count }).strict().nullable() }).superRefine(verifyPopulation).superRefine((value, context) => {
|
|
6026
6141
|
if (value.totals && value.totals.promptTokens < value.counted)
|
|
6027
6142
|
context.addIssue({ code: "custom", path: ["totals"], message: "Each counted initial request requires a nonempty prompt" });
|
|
6028
6143
|
});
|
|
@@ -6031,28 +6146,28 @@ var SftPopulation = Population.extend({ totals: SftTokens.nullable() }).superRef
|
|
|
6031
6146
|
context.addIssue({ code: "custom", path: ["totals"], message: "Each counted SFT row requires context and a complete target" });
|
|
6032
6147
|
});
|
|
6033
6148
|
var Common = {
|
|
6034
|
-
schemaVersion:
|
|
6149
|
+
schemaVersion: z52.literal("openpond.trainingEstimateWorkload.v1"),
|
|
6035
6150
|
identity: Identity.nullable(),
|
|
6036
6151
|
/** Required when immutable identity or native preprocessing cannot be verified. */
|
|
6037
6152
|
unavailableReason: Reason.nullable()
|
|
6038
6153
|
};
|
|
6039
|
-
var TrainingEstimateWorkloadSchema =
|
|
6040
|
-
|
|
6154
|
+
var TrainingEstimateWorkloadSchema = z52.discriminatedUnion("method", [
|
|
6155
|
+
z52.object({
|
|
6041
6156
|
...Common,
|
|
6042
|
-
method:
|
|
6157
|
+
method: z52.literal("sft"),
|
|
6043
6158
|
preprocessing: Preprocessing.extend({
|
|
6044
6159
|
maxSequenceLength: Count.min(2),
|
|
6045
|
-
promptTruncation:
|
|
6046
|
-
targetMask:
|
|
6160
|
+
promptTruncation: z52.literal("left_preserve_complete_target"),
|
|
6161
|
+
targetMask: z52.literal("completion_only")
|
|
6047
6162
|
}).strict().nullable(),
|
|
6048
6163
|
/** One exposure per distinct admitted row, before schedule repetition. */
|
|
6049
6164
|
trainingRows: SftPopulation,
|
|
6050
6165
|
evaluationRows: Count.nullable(),
|
|
6051
6166
|
/** Initial held-out requests only; held-out targets never enter SFT loss. */
|
|
6052
6167
|
evaluationInitialRequests: PromptPopulation,
|
|
6053
|
-
evaluationGeneratedCompletionTokens:
|
|
6168
|
+
evaluationGeneratedCompletionTokens: z52.null(),
|
|
6054
6169
|
evaluationGeneratedTokensReason: Reason,
|
|
6055
|
-
planned:
|
|
6170
|
+
planned: z52.object({
|
|
6056
6171
|
/** Native seeded epoch order, capped by maxSteps × batch × accumulation. */
|
|
6057
6172
|
exampleExposures: Count.nullable(),
|
|
6058
6173
|
optimizerSteps: Count.nullable(),
|
|
@@ -6062,13 +6177,13 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6062
6177
|
reason: Reason.nullable()
|
|
6063
6178
|
}).strict()
|
|
6064
6179
|
}).strict(),
|
|
6065
|
-
|
|
6180
|
+
z52.object({
|
|
6066
6181
|
...Common,
|
|
6067
|
-
method:
|
|
6182
|
+
method: z52.literal("grpo"),
|
|
6068
6183
|
preprocessing: Preprocessing.extend({
|
|
6069
6184
|
maxPromptTokens: Count.positive(),
|
|
6070
|
-
contextAdmission:
|
|
6071
|
-
addGenerationPrompt:
|
|
6185
|
+
contextAdmission: z52.literal("native_policy_context"),
|
|
6186
|
+
addGenerationPrompt: z52.literal(true)
|
|
6072
6187
|
}).strict().nullable(),
|
|
6073
6188
|
/** Distinct released rows, independent of repeated group/slot requests. */
|
|
6074
6189
|
trainingRows: Count.nullable(),
|
|
@@ -6077,8 +6192,8 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6077
6192
|
trainingInitialRequests: PromptPopulation,
|
|
6078
6193
|
evaluationInitialRequests: PromptPopulation,
|
|
6079
6194
|
/** Future generations and tool trajectories have no exact preflight count. */
|
|
6080
|
-
generatedCompletionTokens:
|
|
6081
|
-
subsequentToolTurnPromptTokens:
|
|
6195
|
+
generatedCompletionTokens: z52.null(),
|
|
6196
|
+
subsequentToolTurnPromptTokens: z52.null(),
|
|
6082
6197
|
generatedTokensReason: Reason
|
|
6083
6198
|
}).strict()
|
|
6084
6199
|
]).superRefine((workload, context) => {
|
|
@@ -6110,30 +6225,30 @@ var TrainingEstimateWorkloadSchema = z50.discriminatedUnion("method", [
|
|
|
6110
6225
|
});
|
|
6111
6226
|
|
|
6112
6227
|
// src/training-estimates.ts
|
|
6113
|
-
var Id35 =
|
|
6114
|
-
var Hash39 =
|
|
6115
|
-
var Timestamp3 =
|
|
6116
|
-
var NonNegative =
|
|
6117
|
-
var TrainingEstimateSourceSchema =
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
kind:
|
|
6228
|
+
var Id35 = z53.string().trim().min(1).max(191);
|
|
6229
|
+
var Hash39 = z53.string().regex(/^[a-f0-9]{64}$/);
|
|
6230
|
+
var Timestamp3 = z53.string().datetime({ offset: true });
|
|
6231
|
+
var NonNegative = z53.number().finite().nonnegative();
|
|
6232
|
+
var TrainingEstimateSourceSchema = z53.discriminatedUnion("kind", [
|
|
6233
|
+
z53.object({ kind: z53.literal("preparation"), id: Id35, planHash: Hash39, expectedRevision: z53.number().int().positive() }).strict(),
|
|
6234
|
+
z53.object({
|
|
6235
|
+
kind: z53.literal("configuration"),
|
|
6121
6236
|
id: Id35,
|
|
6122
|
-
expectedRevision:
|
|
6237
|
+
expectedRevision: z53.number().int().positive(),
|
|
6123
6238
|
expectedEtag: Hash39,
|
|
6124
6239
|
batch: ModelProjectVersionedRefSchema.nullable().default(null)
|
|
6125
6240
|
}).strict(),
|
|
6126
|
-
|
|
6241
|
+
z53.object({ kind: z53.literal("submission"), submission: z53.lazy(() => TrainingJobSubmissionSchema) }).strict()
|
|
6127
6242
|
]);
|
|
6128
|
-
var TrainingEstimateRequestSchema =
|
|
6129
|
-
schemaVersion:
|
|
6243
|
+
var TrainingEstimateRequestSchema = z53.object({
|
|
6244
|
+
schemaVersion: z53.literal("openpond.trainingEstimateRequest.v1"),
|
|
6130
6245
|
teamId: Id35,
|
|
6131
6246
|
source: TrainingEstimateSourceSchema,
|
|
6132
6247
|
gpuSelection: TrainingGpuSelectionSchema.optional()
|
|
6133
6248
|
}).strict();
|
|
6134
|
-
var PlanningRange =
|
|
6135
|
-
var TrainingEstimateComponentSchema =
|
|
6136
|
-
phase:
|
|
6249
|
+
var PlanningRange = z53.object({ low: NonNegative, high: NonNegative }).strict().refine((value) => value.high >= value.low, "Planning range must be ordered");
|
|
6250
|
+
var TrainingEstimateComponentSchema = z53.object({
|
|
6251
|
+
phase: z53.enum([
|
|
6137
6252
|
"gpu_allocation",
|
|
6138
6253
|
"startup",
|
|
6139
6254
|
"baseline_evaluation",
|
|
@@ -6146,12 +6261,12 @@ var TrainingEstimateComponentSchema = z51.object({
|
|
|
6146
6261
|
"cleanup",
|
|
6147
6262
|
"retention"
|
|
6148
6263
|
]),
|
|
6149
|
-
resource:
|
|
6264
|
+
resource: z53.enum(["gpu", "cpu", "judge", "storage", "network"]),
|
|
6150
6265
|
expectedUsd: NonNegative.nullable(),
|
|
6151
6266
|
expectedSeconds: NonNegative.nullable(),
|
|
6152
6267
|
planningRangeUsd: PlanningRange.nullable(),
|
|
6153
|
-
evidence:
|
|
6154
|
-
reason:
|
|
6268
|
+
evidence: z53.enum(["measured", "configured_rate", "unavailable"]),
|
|
6269
|
+
reason: z53.string().trim().min(1).max(1e3).nullable()
|
|
6155
6270
|
}).strict();
|
|
6156
6271
|
function trainingEstimateSourceIdentity(source) {
|
|
6157
6272
|
if (source.kind === "submission") return {
|
|
@@ -6168,67 +6283,67 @@ function trainingEstimateSourceIdentity(source) {
|
|
|
6168
6283
|
};
|
|
6169
6284
|
return { kind: source.kind, id: source.id, contentHash: source.expectedEtag, revision: source.expectedRevision };
|
|
6170
6285
|
}
|
|
6171
|
-
var TrainingEstimateSchema =
|
|
6172
|
-
schemaVersion:
|
|
6286
|
+
var TrainingEstimateSchema = z53.object({
|
|
6287
|
+
schemaVersion: z53.literal("openpond.trainingEstimate.v1"),
|
|
6173
6288
|
id: Id35,
|
|
6174
6289
|
teamId: Id35,
|
|
6175
6290
|
requestHash: Hash39,
|
|
6176
6291
|
inputHash: Hash39,
|
|
6177
|
-
source:
|
|
6178
|
-
kind:
|
|
6179
|
-
id:
|
|
6292
|
+
source: z53.object({
|
|
6293
|
+
kind: z53.enum(["preparation", "configuration", "submission"]),
|
|
6294
|
+
id: z53.string().trim().min(1).max(500),
|
|
6180
6295
|
contentHash: Hash39,
|
|
6181
|
-
revision:
|
|
6296
|
+
revision: z53.number().int().positive().nullable()
|
|
6182
6297
|
}).strict(),
|
|
6183
|
-
status:
|
|
6184
|
-
currency:
|
|
6298
|
+
status: z53.enum(["available", "partial", "insufficient_evidence"]),
|
|
6299
|
+
currency: z53.literal("USD"),
|
|
6185
6300
|
createdAt: Timestamp3,
|
|
6186
6301
|
expiresAt: Timestamp3,
|
|
6187
6302
|
estimatorVersion: Id35,
|
|
6188
6303
|
runtimeVersion: Id35,
|
|
6189
|
-
pricing:
|
|
6190
|
-
gpu:
|
|
6304
|
+
pricing: z53.object({ version: Id35, quoteExpiresAt: Timestamp3.nullable() }).strict(),
|
|
6305
|
+
gpu: z53.object({
|
|
6191
6306
|
requested: TrainingGpuSelectionSchema,
|
|
6192
|
-
resolved:
|
|
6307
|
+
resolved: z53.object({ availabilityId: Id35, gpuType: z53.string().min(1).max(256), gpuCount: z53.union([z53.literal(1), z53.literal(2)]) }).strict().nullable(),
|
|
6193
6308
|
customerHourlyUsd: NonNegative.nullable(),
|
|
6194
|
-
availability:
|
|
6309
|
+
availability: z53.enum(["available", "limited", "unavailable", "unknown"])
|
|
6195
6310
|
}).strict(),
|
|
6196
|
-
configuration:
|
|
6311
|
+
configuration: z53.object({
|
|
6197
6312
|
modelId: Id35,
|
|
6198
|
-
modelRevision:
|
|
6313
|
+
modelRevision: z53.string().min(1).max(256),
|
|
6199
6314
|
method: Id35,
|
|
6200
|
-
loraRank:
|
|
6201
|
-
adapterMode:
|
|
6202
|
-
groups:
|
|
6203
|
-
rolloutConcurrency:
|
|
6204
|
-
maxOutputTokens:
|
|
6205
|
-
trainingRows:
|
|
6206
|
-
evaluationRows:
|
|
6207
|
-
retentionDays:
|
|
6315
|
+
loraRank: z53.number().int().positive().nullable(),
|
|
6316
|
+
adapterMode: z53.enum(["residual_append", "shared", "sequential_merge"]).nullable(),
|
|
6317
|
+
groups: z53.number().int().nonnegative().nullable(),
|
|
6318
|
+
rolloutConcurrency: z53.number().int().positive().nullable(),
|
|
6319
|
+
maxOutputTokens: z53.number().int().positive().nullable(),
|
|
6320
|
+
trainingRows: z53.number().int().nonnegative().nullable(),
|
|
6321
|
+
evaluationRows: z53.number().int().nonnegative().nullable(),
|
|
6322
|
+
retentionDays: z53.number().int().positive().nullable(),
|
|
6208
6323
|
approvedMaximumUsd: NonNegative.nullable()
|
|
6209
6324
|
}).strict(),
|
|
6210
6325
|
/** Producers bind supplied evidence into inputHash. Absence has no default and
|
|
6211
6326
|
* preserves the identity of estimates produced before native token preflight. */
|
|
6212
6327
|
workload: TrainingEstimateWorkloadSchema.optional(),
|
|
6213
|
-
cost:
|
|
6328
|
+
cost: z53.object({
|
|
6214
6329
|
expectedUsd: NonNegative.nullable(),
|
|
6215
6330
|
planningRangeUsd: PlanningRange.nullable(),
|
|
6216
6331
|
knownMinimumUsd: NonNegative,
|
|
6217
6332
|
recommendedMaximumUsd: NonNegative.nullable(),
|
|
6218
6333
|
minimumCleanupReserveUsd: NonNegative.nullable(),
|
|
6219
|
-
components:
|
|
6334
|
+
components: z53.array(TrainingEstimateComponentSchema).max(50)
|
|
6220
6335
|
}).strict(),
|
|
6221
|
-
executionSeconds:
|
|
6222
|
-
queueWaitSeconds:
|
|
6223
|
-
calibration:
|
|
6336
|
+
executionSeconds: z53.object({ expected: NonNegative.nullable(), planningRange: PlanningRange.nullable() }).strict(),
|
|
6337
|
+
queueWaitSeconds: z53.object({ expected: NonNegative, planningRange: PlanningRange.nullable() }).strict().nullable(),
|
|
6338
|
+
calibration: z53.object({
|
|
6224
6339
|
version: Id35,
|
|
6225
6340
|
cohortHash: Hash39,
|
|
6226
|
-
completedSamples:
|
|
6227
|
-
partialSamples:
|
|
6228
|
-
scope:
|
|
6341
|
+
completedSamples: z53.number().int().nonnegative(),
|
|
6342
|
+
partialSamples: z53.number().int().nonnegative(),
|
|
6343
|
+
scope: z53.enum(["workspace", "authorized_aggregate"])
|
|
6229
6344
|
}).strict(),
|
|
6230
|
-
assumptions:
|
|
6231
|
-
unknowns:
|
|
6345
|
+
assumptions: z53.array(z53.string().trim().min(1).max(1e3)).max(50),
|
|
6346
|
+
unknowns: z53.array(z53.string().trim().min(1).max(1e3)).max(50),
|
|
6232
6347
|
review: TrainingEstimateReviewSchema
|
|
6233
6348
|
}).strict().superRefine((estimate, context) => {
|
|
6234
6349
|
const allocation = estimate.cost.components.filter((component) => component.phase === "gpu_allocation");
|
|
@@ -6315,7 +6430,7 @@ async function parseAndVerifyTrainingEstimate(raw, request) {
|
|
|
6315
6430
|
}
|
|
6316
6431
|
}
|
|
6317
6432
|
} else if (workload.method === "grpo" && workload.preprocessing) {
|
|
6318
|
-
const recipe =
|
|
6433
|
+
const recipe = z53.object({ dataset: z53.object({ maxPromptTokens: z53.number().int().positive() }) }).safeParse(submission.job.recipe);
|
|
6319
6434
|
mismatch2 ||= !recipe.success || workload.preprocessing.maxPromptTokens !== recipe.data.dataset.maxPromptTokens;
|
|
6320
6435
|
}
|
|
6321
6436
|
if (mismatch2) throw new OpenPondProtocolError("training_estimate_scope_mismatch", "Workload evidence does not match the exact submitted model, recipe and released data.");
|
|
@@ -6329,34 +6444,34 @@ async function parseAndVerifyTrainingEstimate(raw, request) {
|
|
|
6329
6444
|
}
|
|
6330
6445
|
|
|
6331
6446
|
// 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 =
|
|
6447
|
+
import { z as z54 } from "zod";
|
|
6448
|
+
var Id36 = z54.string().trim().min(1).max(240);
|
|
6449
|
+
var Hash40 = z54.string().regex(/^[a-f0-9]{64}$/);
|
|
6450
|
+
var Amount = z54.number().positive().max(1e6);
|
|
6451
|
+
var Decimal = z54.string().regex(/^\d+(?:\.\d{1,6})?$/);
|
|
6452
|
+
var Timestamp4 = z54.iso.datetime();
|
|
6453
|
+
var TrainingFundingDraftRefSchema = z54.object({
|
|
6339
6454
|
id: Id36,
|
|
6340
|
-
revision:
|
|
6455
|
+
revision: z54.number().int().positive(),
|
|
6341
6456
|
contentHash: Hash40,
|
|
6342
6457
|
projectId: Id36.nullable()
|
|
6343
6458
|
}).strict();
|
|
6344
|
-
var TrainingFundingRequestSchema =
|
|
6345
|
-
schemaVersion:
|
|
6459
|
+
var TrainingFundingRequestSchema = z54.object({
|
|
6460
|
+
schemaVersion: z54.literal("openpond.trainingFundingRequest.v1"),
|
|
6346
6461
|
teamId: Id36,
|
|
6347
6462
|
maximumSpendUsd: Amount,
|
|
6348
6463
|
draft: TrainingFundingDraftRefSchema.nullable().default(null)
|
|
6349
6464
|
}).strict();
|
|
6350
|
-
var TrainingFundingSchema =
|
|
6351
|
-
schemaVersion:
|
|
6465
|
+
var TrainingFundingSchema = z54.object({
|
|
6466
|
+
schemaVersion: z54.literal("openpond.trainingFunding.v1"),
|
|
6352
6467
|
teamId: Id36,
|
|
6353
6468
|
actorId: Id36,
|
|
6354
6469
|
requestHash: Hash40,
|
|
6355
6470
|
maximumSpendUsd: Amount,
|
|
6356
6471
|
draft: TrainingFundingDraftRefSchema.nullable(),
|
|
6357
|
-
state:
|
|
6358
|
-
canViewBalance:
|
|
6359
|
-
canPurchase:
|
|
6472
|
+
state: z54.enum(["covered", "insufficient_credit", "member_limit", "unavailable"]),
|
|
6473
|
+
canViewBalance: z54.boolean(),
|
|
6474
|
+
canPurchase: z54.boolean(),
|
|
6360
6475
|
availableUsageUsd: Decimal.nullable(),
|
|
6361
6476
|
prepaidCreditUsd: Decimal.nullable(),
|
|
6362
6477
|
checkedAt: Timestamp4,
|
|
@@ -6367,21 +6482,21 @@ var TrainingFundingSchema = z52.object({
|
|
|
6367
6482
|
if (Date.parse(value.expiresAt) <= Date.parse(value.checkedAt))
|
|
6368
6483
|
context.addIssue({ code: "custom", path: ["expiresAt"], message: "Funding observations must expire after their check." });
|
|
6369
6484
|
});
|
|
6370
|
-
var TrainingFundingHandoffRequestSchema =
|
|
6371
|
-
schemaVersion:
|
|
6485
|
+
var TrainingFundingHandoffRequestSchema = z54.object({
|
|
6486
|
+
schemaVersion: z54.literal("openpond.trainingFundingHandoffRequest.v1"),
|
|
6372
6487
|
teamId: Id36,
|
|
6373
6488
|
maximumSpendUsd: Amount.nullable(),
|
|
6374
6489
|
draft: TrainingFundingDraftRefSchema
|
|
6375
6490
|
}).strict();
|
|
6376
|
-
var TrainingFundingHandoffSchema =
|
|
6377
|
-
schemaVersion:
|
|
6491
|
+
var TrainingFundingHandoffSchema = z54.object({
|
|
6492
|
+
schemaVersion: z54.literal("openpond.trainingFundingHandoff.v1"),
|
|
6378
6493
|
teamId: Id36,
|
|
6379
6494
|
actorId: Id36,
|
|
6380
6495
|
requestHash: Hash40,
|
|
6381
6496
|
maximumSpendUsd: Amount.nullable(),
|
|
6382
6497
|
draft: TrainingFundingDraftRefSchema,
|
|
6383
|
-
canPurchase:
|
|
6384
|
-
billingUrl:
|
|
6498
|
+
canPurchase: z54.boolean(),
|
|
6499
|
+
billingUrl: z54.string().url().nullable(),
|
|
6385
6500
|
checkedAt: Timestamp4,
|
|
6386
6501
|
expiresAt: Timestamp4
|
|
6387
6502
|
}).strict().superRefine((value, context) => {
|
|
@@ -6424,8 +6539,8 @@ function createTrainingFundingClient(request) {
|
|
|
6424
6539
|
async function parseAndVerifyDatasetTrainingReviewReceipt(raw, input, actorId) {
|
|
6425
6540
|
const request = DatasetTrainingReviewRequestSchema.parse(input);
|
|
6426
6541
|
const value = DatasetTrainingReviewReceiptSchema.parse(raw);
|
|
6427
|
-
const { contentHash, ...content } = value;
|
|
6428
|
-
if (
|
|
6542
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
6543
|
+
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
6544
|
throw new OpenPondProtocolError("dataset_training_review_mismatch", "The Dataset review receipt differs from its exact source or operation.");
|
|
6430
6545
|
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
6546
|
throw new OpenPondProtocolError("dataset_training_review_inventory_mismatch", "The Dataset review returned another example inventory.");
|
|
@@ -6444,37 +6559,37 @@ function createDatasetTrainingReviewClient(request) {
|
|
|
6444
6559
|
}
|
|
6445
6560
|
|
|
6446
6561
|
// src/training-model-save.ts
|
|
6447
|
-
import { z as
|
|
6448
|
-
var Id37 =
|
|
6449
|
-
var Hash41 =
|
|
6450
|
-
var TrainingResultSaveRequestSchema =
|
|
6451
|
-
schemaVersion:
|
|
6562
|
+
import { z as z55 } from "zod";
|
|
6563
|
+
var Id37 = z55.string().trim().min(1).max(200);
|
|
6564
|
+
var Hash41 = z55.string().regex(/^[a-f0-9]{64}$/);
|
|
6565
|
+
var TrainingResultSaveRequestSchema = z55.object({
|
|
6566
|
+
schemaVersion: z55.literal("openpond.trainingResultSave.v1"),
|
|
6452
6567
|
teamId: Id37,
|
|
6453
6568
|
operationId: Id37,
|
|
6454
|
-
name:
|
|
6455
|
-
expectedModelRevision:
|
|
6569
|
+
name: z55.string().trim().min(1).max(200),
|
|
6570
|
+
expectedModelRevision: z55.number().int().positive(),
|
|
6456
6571
|
submissionHash: Hash41,
|
|
6457
6572
|
artifact: ModelProjectImmutableRefSchema,
|
|
6458
6573
|
checkpointId: Id37
|
|
6459
6574
|
}).strict();
|
|
6460
6575
|
var TrainingResultSaveIntentSchema = TrainingResultSaveRequestSchema.omit({ operationId: true }).extend({ jobId: Id37 }).strict();
|
|
6461
|
-
var TrainingResultSaveCommandSchema =
|
|
6462
|
-
var TrainingResultSaveReceiptSchema =
|
|
6463
|
-
schemaVersion:
|
|
6576
|
+
var TrainingResultSaveCommandSchema = z55.object({ jobId: Id37, request: TrainingResultSaveRequestSchema }).strict();
|
|
6577
|
+
var TrainingResultSaveReceiptSchema = z55.object({
|
|
6578
|
+
schemaVersion: z55.literal("openpond.trainingResultSaveReceipt.v1"),
|
|
6464
6579
|
teamId: Id37,
|
|
6465
6580
|
actorId: Id37,
|
|
6466
6581
|
operationId: Id37,
|
|
6467
6582
|
requestHash: Hash41,
|
|
6468
|
-
model:
|
|
6469
|
-
version:
|
|
6583
|
+
model: z55.lazy(() => HostedModelProjectSummarySchema),
|
|
6584
|
+
version: z55.lazy(() => TrainingModelVersionSchema),
|
|
6470
6585
|
contentHash: Hash41
|
|
6471
6586
|
}).strict();
|
|
6472
|
-
var TrainingSavedModelQuerySchema =
|
|
6473
|
-
var TrainingSavedModelSchema =
|
|
6474
|
-
schemaVersion:
|
|
6587
|
+
var TrainingSavedModelQuerySchema = z55.object({ teamId: Id37 }).strict();
|
|
6588
|
+
var TrainingSavedModelSchema = z55.object({
|
|
6589
|
+
schemaVersion: z55.literal("openpond.trainingSavedModel.v1"),
|
|
6475
6590
|
teamId: Id37,
|
|
6476
|
-
model:
|
|
6477
|
-
version:
|
|
6591
|
+
model: z55.lazy(() => HostedModelProjectSummarySchema),
|
|
6592
|
+
version: z55.lazy(() => TrainingModelVersionSchema).nullable()
|
|
6478
6593
|
}).strict();
|
|
6479
6594
|
async function parseAndVerifyTrainingSavedModel(raw, expected) {
|
|
6480
6595
|
const value = TrainingSavedModelSchema.parse(raw);
|
|
@@ -6490,9 +6605,9 @@ async function parseAndVerifyTrainingSavedModel(raw, expected) {
|
|
|
6490
6605
|
async function parseAndVerifyTrainingResultSave(raw, expected) {
|
|
6491
6606
|
const value = TrainingResultSaveReceiptSchema.parse(raw);
|
|
6492
6607
|
const request = TrainingResultSaveRequestSchema.parse(expected.request);
|
|
6493
|
-
const { contentHash, ...content } = value;
|
|
6608
|
+
const { contentHash: contentHash2, ...content } = value;
|
|
6494
6609
|
const version = await parseAndVerifyTrainingModelVersion(value.version, { teamId: request.teamId, modelProjectId: value.model.id, jobId: expected.jobId });
|
|
6495
|
-
if (
|
|
6610
|
+
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
6611
|
throw new OpenPondProtocolError("training_result_save_mismatch", "The saved Model differs from the reviewed training result or name.");
|
|
6497
6612
|
return value;
|
|
6498
6613
|
}
|
|
@@ -6513,47 +6628,47 @@ function createTrainingModelSaveClient(request) {
|
|
|
6513
6628
|
}
|
|
6514
6629
|
|
|
6515
6630
|
// src/training-model-serving.ts
|
|
6516
|
-
import { z as
|
|
6631
|
+
import { z as z57 } from "zod";
|
|
6517
6632
|
|
|
6518
6633
|
// src/training-model-serving-control.ts
|
|
6519
|
-
import { z as
|
|
6520
|
-
var Id38 =
|
|
6521
|
-
var Hash42 =
|
|
6522
|
-
var TrainingModelServingControlSchema =
|
|
6634
|
+
import { z as z56 } from "zod";
|
|
6635
|
+
var Id38 = z56.string().trim().min(1).max(500);
|
|
6636
|
+
var Hash42 = z56.string().regex(/^[a-f0-9]{64}$/);
|
|
6637
|
+
var TrainingModelServingControlSchema = z56.object({
|
|
6523
6638
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
6524
|
-
schemaVersion:
|
|
6639
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControl.v1"),
|
|
6525
6640
|
teamId: Id38,
|
|
6526
6641
|
modelProjectId: Id38,
|
|
6527
6642
|
versionHash: Hash42,
|
|
6528
6643
|
artifact: ModelProjectImmutableRefSchema,
|
|
6529
6644
|
actorId: Id38,
|
|
6530
6645
|
operationId: Id38,
|
|
6531
|
-
revision:
|
|
6532
|
-
desiredState:
|
|
6533
|
-
phase:
|
|
6534
|
-
capacityState:
|
|
6646
|
+
revision: z56.number().int().positive(),
|
|
6647
|
+
desiredState: z56.enum(["active", "stopped"]),
|
|
6648
|
+
phase: z56.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
6649
|
+
capacityState: z56.enum(["pending", "shared", "retiring", "released"]),
|
|
6535
6650
|
modelId: Id38,
|
|
6536
6651
|
deploymentId: Id38,
|
|
6537
6652
|
poolId: Id38,
|
|
6538
|
-
idleTimeoutSeconds:
|
|
6653
|
+
idleTimeoutSeconds: z56.number().int().min(60).max(3600),
|
|
6539
6654
|
failureCode: Id38.nullable(),
|
|
6540
|
-
updatedAt:
|
|
6655
|
+
updatedAt: z56.string().datetime({ offset: true })
|
|
6541
6656
|
}).strict();
|
|
6542
|
-
var TrainingModelServingControlRequestSchema =
|
|
6657
|
+
var TrainingModelServingControlRequestSchema = z56.object({
|
|
6543
6658
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
6544
|
-
schemaVersion:
|
|
6659
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControlRequest.v1"),
|
|
6545
6660
|
teamId: Id38,
|
|
6546
6661
|
operationId: Id38,
|
|
6547
6662
|
artifact: ModelProjectImmutableRefSchema,
|
|
6548
6663
|
versionHash: Hash42,
|
|
6549
|
-
expectedRevision:
|
|
6550
|
-
action:
|
|
6551
|
-
idleTimeoutSeconds:
|
|
6664
|
+
expectedRevision: z56.number().int().nonnegative(),
|
|
6665
|
+
action: z56.enum(["activate", "stop"]),
|
|
6666
|
+
idleTimeoutSeconds: z56.number().int().min(60).max(3600)
|
|
6552
6667
|
}).strict();
|
|
6553
6668
|
var TrainingModelServingControlIntentSchema = TrainingModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id38 }).strict();
|
|
6554
|
-
var TrainingModelServingControlCommandSchema =
|
|
6555
|
-
var TrainingModelServingControlReceiptSchema =
|
|
6556
|
-
schemaVersion:
|
|
6669
|
+
var TrainingModelServingControlCommandSchema = z56.object({ modelProjectId: Id38, request: TrainingModelServingControlRequestSchema }).strict();
|
|
6670
|
+
var TrainingModelServingControlReceiptSchema = z56.object({
|
|
6671
|
+
schemaVersion: z56.literal("openpond.trainingModelServingControlReceipt.v1"),
|
|
6557
6672
|
teamId: Id38,
|
|
6558
6673
|
modelProjectId: Id38,
|
|
6559
6674
|
actorId: Id38,
|
|
@@ -6563,8 +6678,8 @@ var TrainingModelServingControlReceiptSchema = z54.object({
|
|
|
6563
6678
|
}).strict();
|
|
6564
6679
|
async function parseAndVerifyTrainingModelServingControl(raw, expected) {
|
|
6565
6680
|
const value = TrainingModelServingControlReceiptSchema.parse(raw), request = TrainingModelServingControlRequestSchema.parse(expected.request);
|
|
6566
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
6567
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
6681
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
6682
|
+
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
6683
|
throw new OpenPondProtocolError("training_model_serving_control_mismatch", "The serving command differs from its reviewed Model, version or action.");
|
|
6569
6684
|
return value;
|
|
6570
6685
|
}
|
|
@@ -6579,56 +6694,56 @@ function createTrainingModelServingControlClient(request) {
|
|
|
6579
6694
|
}
|
|
6580
6695
|
|
|
6581
6696
|
// src/training-model-serving.ts
|
|
6582
|
-
var Id39 =
|
|
6583
|
-
var Hash43 =
|
|
6584
|
-
var Timestamp5 =
|
|
6585
|
-
var TrainingModelServingQuerySchema =
|
|
6586
|
-
var TrainingServingVersionSchema =
|
|
6587
|
-
var TrainingServingRegistrySchema =
|
|
6697
|
+
var Id39 = z57.string().trim().min(1).max(500);
|
|
6698
|
+
var Hash43 = z57.string().regex(/^[a-f0-9]{64}$/);
|
|
6699
|
+
var Timestamp5 = z57.string().datetime({ offset: true });
|
|
6700
|
+
var TrainingModelServingQuerySchema = z57.object({ teamId: Id39, versionHash: Hash43 }).strict();
|
|
6701
|
+
var TrainingServingVersionSchema = z57.lazy(() => TrainingModelVersionSchema);
|
|
6702
|
+
var TrainingServingRegistrySchema = z57.object({
|
|
6588
6703
|
artifact: ModelProjectImmutableRefSchema,
|
|
6589
6704
|
baseProfileId: Id39,
|
|
6590
6705
|
state: Id39,
|
|
6591
|
-
qualified:
|
|
6592
|
-
revoked:
|
|
6593
|
-
deleted:
|
|
6594
|
-
reason:
|
|
6595
|
-
source:
|
|
6706
|
+
qualified: z57.boolean(),
|
|
6707
|
+
revoked: z57.boolean(),
|
|
6708
|
+
deleted: z57.boolean(),
|
|
6709
|
+
reason: z57.enum(["qualified", "evaluation_pending", "post_training_pending", "evaluation_failed", "candidate_rejected", "artifact_revoked", "artifact_deleted", "runtime_unavailable"]),
|
|
6710
|
+
source: z57.object({ jobId: Id39, artifact: ModelProjectImmutableRefSchema, checkpointId: Id39 }).strict()
|
|
6596
6711
|
}).strict();
|
|
6597
|
-
var TrainingServingDeploymentSchema =
|
|
6712
|
+
var TrainingServingDeploymentSchema = z57.object({
|
|
6598
6713
|
id: Id39,
|
|
6599
6714
|
artifactId: Id39,
|
|
6600
6715
|
poolId: Id39.nullable(),
|
|
6601
|
-
revision:
|
|
6602
|
-
state:
|
|
6603
|
-
revoked:
|
|
6716
|
+
revision: z57.number().int().positive(),
|
|
6717
|
+
state: z57.enum(["requested", "deploying", "ready", "degraded", "deleting", "deleted", "failed"]),
|
|
6718
|
+
revoked: z57.boolean(),
|
|
6604
6719
|
lastReadyCheckAt: Timestamp5.nullable(),
|
|
6605
6720
|
updatedAt: Timestamp5
|
|
6606
6721
|
}).strict();
|
|
6607
|
-
var TrainingServingBindingSchema =
|
|
6608
|
-
var TrainingServingLoadEvidenceSchema =
|
|
6722
|
+
var TrainingServingBindingSchema = z57.object({ id: Id39, modelId: Id39, artifactId: Id39, deploymentId: Id39, revision: z57.number().int().positive() }).strict();
|
|
6723
|
+
var TrainingServingLoadEvidenceSchema = z57.object({
|
|
6609
6724
|
requestId: Id39,
|
|
6610
6725
|
receipt: ModelProjectImmutableRefSchema,
|
|
6611
6726
|
artifact: ModelProjectImmutableRefSchema,
|
|
6612
6727
|
deploymentId: Id39,
|
|
6613
6728
|
poolId: Id39,
|
|
6614
|
-
workerImageDigest:
|
|
6729
|
+
workerImageDigest: z57.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
6615
6730
|
completedAt: Timestamp5
|
|
6616
6731
|
}).strict();
|
|
6617
|
-
var TrainingModelServingContentSchema =
|
|
6732
|
+
var TrainingModelServingContentSchema = z57.object({
|
|
6618
6733
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
6619
|
-
schemaVersion:
|
|
6734
|
+
schemaVersion: z57.literal("openpond.trainingModelServing.v1"),
|
|
6620
6735
|
teamId: Id39,
|
|
6621
6736
|
modelProjectId: Id39,
|
|
6622
6737
|
observedAt: Timestamp5,
|
|
6623
6738
|
version: TrainingServingVersionSchema,
|
|
6624
6739
|
registry: TrainingServingRegistrySchema.nullable(),
|
|
6625
6740
|
control: TrainingModelServingControlSchema.nullable(),
|
|
6626
|
-
cleanup:
|
|
6627
|
-
deployments:
|
|
6628
|
-
pools:
|
|
6629
|
-
bindings:
|
|
6741
|
+
cleanup: z57.array(TrainingModelServingControlSchema).max(100),
|
|
6742
|
+
deployments: z57.array(TrainingServingDeploymentSchema).max(100),
|
|
6743
|
+
pools: z57.array(TrainingServingPoolSchema).max(100),
|
|
6744
|
+
bindings: z57.array(TrainingServingBindingSchema).max(100),
|
|
6630
6745
|
lastVerifiedInference: TrainingServingLoadEvidenceSchema.nullable(),
|
|
6631
|
-
state:
|
|
6746
|
+
state: z57.enum(["unpublished", "qualification_pending", "unavailable", "inactive", "starting", "active", "retiring"])
|
|
6632
6747
|
}).strict();
|
|
6633
6748
|
var TrainingModelServingSchema = TrainingModelServingContentSchema.extend({ contentHash: Hash43 }).strict();
|
|
6634
6749
|
function trainingModelServingState(value) {
|
|
@@ -6644,13 +6759,13 @@ function trainingModelServingState(value) {
|
|
|
6644
6759
|
return value.bindings.length ? "unavailable" : "inactive";
|
|
6645
6760
|
}
|
|
6646
6761
|
async function parseAndVerifyTrainingModelServing(raw, expected) {
|
|
6647
|
-
const value = TrainingModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
6762
|
+
const value = TrainingModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6648
6763
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "training" }, value.control);
|
|
6649
6764
|
await parseAndVerifyTrainingModelVersion(value.version, expected);
|
|
6650
6765
|
function fail8() {
|
|
6651
6766
|
throw new OpenPondProtocolError("training_model_serving_mismatch", "Serving evidence differs from the exact saved Model, registry or deployment.");
|
|
6652
6767
|
}
|
|
6653
|
-
if (value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash ||
|
|
6768
|
+
if (value.teamId !== expected.teamId || value.modelProjectId !== expected.modelProjectId || value.version.contentHash !== expected.versionHash || contentHash2 !== await canonicalSha256(content) || value.state !== trainingModelServingState(value)) fail8();
|
|
6654
6769
|
for (const rows of [value.deployments, value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
6655
6770
|
const registry = value.registry;
|
|
6656
6771
|
const control2 = value.control;
|
|
@@ -6676,13 +6791,13 @@ function createTrainingModelServingClient(request) {
|
|
|
6676
6791
|
}
|
|
6677
6792
|
|
|
6678
6793
|
// src/steering-model-serving.ts
|
|
6679
|
-
import { z as
|
|
6794
|
+
import { z as z59 } from "zod";
|
|
6680
6795
|
|
|
6681
6796
|
// src/steering-inference.ts
|
|
6682
|
-
import { z as
|
|
6683
|
-
var Hash44 =
|
|
6684
|
-
var Id40 =
|
|
6685
|
-
var SteeringInferenceOptionsSchema =
|
|
6797
|
+
import { z as z58 } from "zod";
|
|
6798
|
+
var Hash44 = z58.string().regex(/^[a-f0-9]{64}$/);
|
|
6799
|
+
var Id40 = z58.string().trim().min(1).max(500);
|
|
6800
|
+
var SteeringInferenceOptionsSchema = z58.object({
|
|
6686
6801
|
savedModel: SavedSteeringModelSelectionSchema.optional(),
|
|
6687
6802
|
steering: SteeringPublicationReferenceSchema.nullable().optional()
|
|
6688
6803
|
}).strict();
|
|
@@ -6691,9 +6806,9 @@ async function savedSteeringModelSelection(raw) {
|
|
|
6691
6806
|
await parseAndVerifySavedModelVersion(version);
|
|
6692
6807
|
return { modelProjectId: version.modelProjectId, versionHash: version.contentHash };
|
|
6693
6808
|
}
|
|
6694
|
-
var ResolvedSteeringSelectionSchema =
|
|
6695
|
-
schemaVersion:
|
|
6696
|
-
requested:
|
|
6809
|
+
var ResolvedSteeringSelectionSchema = z58.object({
|
|
6810
|
+
schemaVersion: z58.literal("openpond.resolvedSteeringSelection.v1"),
|
|
6811
|
+
requested: z58.enum(["inherit", "off", "override"]),
|
|
6697
6812
|
savedModel: SavedSteeringModelSelectionSchema.nullable(),
|
|
6698
6813
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6699
6814
|
effectivePublication: SteeringPublicationReferenceSchema.nullable(),
|
|
@@ -6709,84 +6824,84 @@ async function parseAndVerifyResolvedSteeringSelection(raw, options) {
|
|
|
6709
6824
|
throw new OpenPondProtocolError("steering_selection_mismatch", "The admitted steering selection differs from the exact request and default.");
|
|
6710
6825
|
return value;
|
|
6711
6826
|
}
|
|
6712
|
-
var SteeringInferenceReceiptContentSchema =
|
|
6713
|
-
schemaVersion:
|
|
6827
|
+
var SteeringInferenceReceiptContentSchema = z58.object({
|
|
6828
|
+
schemaVersion: z58.literal("openpond.steeringInferenceReceipt.v1"),
|
|
6714
6829
|
teamId: Id40,
|
|
6715
6830
|
requestId: Id40,
|
|
6716
6831
|
requestHash: Hash44,
|
|
6717
6832
|
selection: ResolvedSteeringSelectionSchema,
|
|
6718
6833
|
poolId: Id40,
|
|
6719
|
-
routingBinding:
|
|
6834
|
+
routingBinding: z58.object({ id: Id40, revision: z58.number().int().positive() }).strict().nullable(),
|
|
6720
6835
|
runtimeHash: Hash44,
|
|
6721
|
-
workerImageDigest:
|
|
6722
|
-
engineGeneration:
|
|
6836
|
+
workerImageDigest: z58.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
6837
|
+
engineGeneration: z58.number().int().positive(),
|
|
6723
6838
|
cacheNamespace: Hash44,
|
|
6724
|
-
completedAt:
|
|
6839
|
+
completedAt: z58.iso.datetime()
|
|
6725
6840
|
}).strict();
|
|
6726
6841
|
var SteeringInferenceReceiptSchema = SteeringInferenceReceiptContentSchema.extend({ contentHash: Hash44 }).strict();
|
|
6727
6842
|
async function parseAndVerifySteeringInferenceReceipt(raw, expected) {
|
|
6728
|
-
const value = SteeringInferenceReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
6843
|
+
const value = SteeringInferenceReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6729
6844
|
await parseAndVerifyResolvedSteeringSelection(value.selection, expected.options);
|
|
6730
|
-
if (
|
|
6845
|
+
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
6846
|
throw new OpenPondProtocolError("steering_inference_receipt_mismatch", "The completed inference differs from its admitted steering, runtime or cache identity.");
|
|
6732
6847
|
return value;
|
|
6733
6848
|
}
|
|
6734
6849
|
|
|
6735
6850
|
// src/steering-model-serving.ts
|
|
6736
|
-
var Id41 =
|
|
6737
|
-
var Hash45 =
|
|
6738
|
-
var BindingRef5 =
|
|
6739
|
-
var Timestamp6 =
|
|
6740
|
-
var SteeringModelServingControlRequestSchema =
|
|
6851
|
+
var Id41 = z59.string().trim().min(1).max(240);
|
|
6852
|
+
var Hash45 = z59.string().regex(/^[a-f0-9]{64}$/);
|
|
6853
|
+
var BindingRef5 = z59.object({ id: Id41, revision: z59.number().int().positive() }).strict();
|
|
6854
|
+
var Timestamp6 = z59.iso.datetime();
|
|
6855
|
+
var SteeringModelServingControlRequestSchema = z59.object({
|
|
6741
6856
|
usageApproval: ManagedServingUsageApprovalSchema.optional(),
|
|
6742
|
-
schemaVersion:
|
|
6857
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControlRequest.v1"),
|
|
6743
6858
|
teamId: Id41,
|
|
6744
6859
|
operationId: Id41,
|
|
6745
6860
|
versionHash: Hash45,
|
|
6746
|
-
expectedRevision:
|
|
6747
|
-
action:
|
|
6861
|
+
expectedRevision: z59.number().int().nonnegative(),
|
|
6862
|
+
action: z59.enum(["activate", "stop"]),
|
|
6748
6863
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6749
|
-
idleTimeoutSeconds:
|
|
6864
|
+
idleTimeoutSeconds: z59.number().int().min(60).max(3600)
|
|
6750
6865
|
}).strict();
|
|
6751
6866
|
var SteeringModelServingControlIntentSchema = SteeringModelServingControlRequestSchema.omit({ operationId: true }).extend({ modelProjectId: Id41 }).strict();
|
|
6752
|
-
var SteeringModelServingControlCommandSchema =
|
|
6753
|
-
var SteeringModelServingControlSchema =
|
|
6867
|
+
var SteeringModelServingControlCommandSchema = z59.object({ modelProjectId: Id41, request: SteeringModelServingControlRequestSchema }).strict();
|
|
6868
|
+
var SteeringModelServingControlSchema = z59.object({
|
|
6754
6869
|
usage: ManagedServingUsageSnapshotSchema.optional(),
|
|
6755
|
-
schemaVersion:
|
|
6870
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControl.v1"),
|
|
6756
6871
|
teamId: Id41,
|
|
6757
6872
|
modelProjectId: Id41,
|
|
6758
6873
|
versionHash: Hash45,
|
|
6759
6874
|
actorId: Id41,
|
|
6760
6875
|
operationId: Id41,
|
|
6761
|
-
revision:
|
|
6876
|
+
revision: z59.number().int().positive(),
|
|
6762
6877
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6763
|
-
desiredState:
|
|
6764
|
-
phase:
|
|
6765
|
-
capacityState:
|
|
6878
|
+
desiredState: z59.enum(["active", "stopped"]),
|
|
6879
|
+
phase: z59.enum(["starting", "active", "stopping", "stopped", "failed"]),
|
|
6880
|
+
capacityState: z59.enum(["pending", "shared", "retiring", "released"]),
|
|
6766
6881
|
modelId: Id41,
|
|
6767
6882
|
poolId: Id41.nullable(),
|
|
6768
6883
|
binding: BindingRef5.nullable(),
|
|
6769
|
-
activeRequests:
|
|
6770
|
-
unsettledRequests:
|
|
6771
|
-
idleTimeoutSeconds:
|
|
6884
|
+
activeRequests: z59.number().int().nonnegative(),
|
|
6885
|
+
unsettledRequests: z59.number().int().nonnegative(),
|
|
6886
|
+
idleTimeoutSeconds: z59.number().int().min(60).max(3600),
|
|
6772
6887
|
failureCode: Id41.nullable(),
|
|
6773
6888
|
updatedAt: Timestamp6
|
|
6774
6889
|
}).strict();
|
|
6775
|
-
var SteeringServingBindingSchema =
|
|
6890
|
+
var SteeringServingBindingSchema = z59.object({
|
|
6776
6891
|
id: Id41,
|
|
6777
|
-
revision:
|
|
6892
|
+
revision: z59.number().int().positive(),
|
|
6778
6893
|
modelId: Id41,
|
|
6779
6894
|
poolId: Id41,
|
|
6780
6895
|
versionHash: Hash45
|
|
6781
6896
|
}).strict();
|
|
6782
|
-
var SteeringServingAvailabilitySchema =
|
|
6783
|
-
state:
|
|
6784
|
-
reason:
|
|
6897
|
+
var SteeringServingAvailabilitySchema = z59.object({
|
|
6898
|
+
state: z59.enum(["qualified", "unavailable"]),
|
|
6899
|
+
reason: z59.enum(["qualified", "runtime_unavailable", "calibration_unavailable", "profile_archived", "model_mismatch"]),
|
|
6785
6900
|
runtimeHash: Hash45.nullable()
|
|
6786
6901
|
}).strict();
|
|
6787
|
-
var SteeringModelServingContentSchema =
|
|
6902
|
+
var SteeringModelServingContentSchema = z59.object({
|
|
6788
6903
|
usageBilling: ManagedServingUsageReviewResultSchema.optional(),
|
|
6789
|
-
schemaVersion:
|
|
6904
|
+
schemaVersion: z59.literal("openpond.steeringModelServing.v1"),
|
|
6790
6905
|
teamId: Id41,
|
|
6791
6906
|
modelProjectId: Id41,
|
|
6792
6907
|
observedAt: Timestamp6,
|
|
@@ -6794,17 +6909,17 @@ var SteeringModelServingContentSchema = z57.object({
|
|
|
6794
6909
|
defaultPublication: SteeringPublicationReferenceSchema.nullable(),
|
|
6795
6910
|
availability: SteeringServingAvailabilitySchema,
|
|
6796
6911
|
control: SteeringModelServingControlSchema.nullable(),
|
|
6797
|
-
cleanup:
|
|
6798
|
-
pools:
|
|
6799
|
-
bindings:
|
|
6912
|
+
cleanup: z59.array(SteeringModelServingControlSchema).max(100),
|
|
6913
|
+
pools: z59.array(TrainingServingPoolSchema).max(100),
|
|
6914
|
+
bindings: z59.array(SteeringServingBindingSchema).max(100),
|
|
6800
6915
|
lastVerifiedInference: SteeringInferenceReceiptSchema.nullable(),
|
|
6801
|
-
state:
|
|
6916
|
+
state: z59.enum(["unavailable", "inactive", "starting", "active", "retiring"])
|
|
6802
6917
|
}).strict();
|
|
6803
6918
|
var SteeringModelServingSchema = SteeringModelServingContentSchema.extend({ contentHash: Hash45 }).strict();
|
|
6804
|
-
var SavedModelServingSchema =
|
|
6919
|
+
var SavedModelServingSchema = z59.discriminatedUnion("schemaVersion", [TrainingModelServingSchema, SteeringModelServingSchema, EngramModelServingSchema, DecisionModelServingSchema, AlphaEditModelServingSchema, NeuronTrainingModelServingSchema]);
|
|
6805
6920
|
var SavedModelServingQuerySchema = TrainingModelServingQuerySchema;
|
|
6806
|
-
var SteeringModelServingControlReceiptContentSchema =
|
|
6807
|
-
schemaVersion:
|
|
6921
|
+
var SteeringModelServingControlReceiptContentSchema = z59.object({
|
|
6922
|
+
schemaVersion: z59.literal("openpond.steeringModelServingControlReceipt.v1"),
|
|
6808
6923
|
teamId: Id41,
|
|
6809
6924
|
modelProjectId: Id41,
|
|
6810
6925
|
actorId: Id41,
|
|
@@ -6817,8 +6932,8 @@ function sameRef(a, b) {
|
|
|
6817
6932
|
return canonicalJson(a) === canonicalJson(b);
|
|
6818
6933
|
}
|
|
6819
6934
|
function publicationRef(version) {
|
|
6820
|
-
const { id, revision, contentHash } = version.publication;
|
|
6821
|
-
return { id, revision, contentHash };
|
|
6935
|
+
const { id, revision, contentHash: contentHash2 } = version.publication;
|
|
6936
|
+
return { id, revision, contentHash: contentHash2 };
|
|
6822
6937
|
}
|
|
6823
6938
|
function validControl5(value) {
|
|
6824
6939
|
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 +6949,20 @@ function steeringModelServingState(value) {
|
|
|
6834
6949
|
}
|
|
6835
6950
|
async function parseAndVerifySteeringModelServingControl(raw, expected) {
|
|
6836
6951
|
const value = SteeringModelServingControlReceiptSchema.parse(raw), request = SteeringModelServingControlRequestSchema.parse(expected.request);
|
|
6837
|
-
const { contentHash, ...content } = value, control2 = value.control;
|
|
6952
|
+
const { contentHash: contentHash2, ...content } = value, control2 = value.control;
|
|
6838
6953
|
await parseAndVerifySavedModelVersion(value.version, { teamId: request.teamId, modelProjectId: expected.modelProjectId });
|
|
6839
|
-
if (!managedServingUsageApprovalMatches(request, control2) ||
|
|
6954
|
+
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
6955
|
throw new OpenPondProtocolError("steering_serving_control_mismatch", "The serving receipt differs from the exact saved steering Model, default or original command.");
|
|
6841
6956
|
return value;
|
|
6842
6957
|
}
|
|
6843
6958
|
async function parseAndVerifySteeringModelServing(raw, expected) {
|
|
6844
|
-
const value = SteeringModelServingSchema.parse(raw), { contentHash, ...content } = value;
|
|
6959
|
+
const value = SteeringModelServingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6845
6960
|
await verifyManagedServingUsageBilling(value.usageBilling, { ...expected, method: "steering" }, value.control);
|
|
6846
6961
|
await parseAndVerifySavedModelVersion(value.version, expected);
|
|
6847
6962
|
function fail8() {
|
|
6848
6963
|
throw new OpenPondProtocolError("steering_model_serving_mismatch", "The serving evidence differs from the exact saved steering Model or retained capacity.");
|
|
6849
6964
|
}
|
|
6850
|
-
if (
|
|
6965
|
+
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
6966
|
for (const rows of [value.pools, value.bindings]) if (new Set(rows.map((row) => row.id)).size !== rows.length) fail8();
|
|
6852
6967
|
for (const control3 of [...value.cleanup, ...value.control ? [value.control] : []]) {
|
|
6853
6968
|
if (control3.teamId !== expected.teamId || control3.modelProjectId !== expected.modelProjectId || !validControl5(control3)) fail8();
|
|
@@ -6895,18 +7010,18 @@ function createSavedModelServingClient(request) {
|
|
|
6895
7010
|
}
|
|
6896
7011
|
|
|
6897
7012
|
// src/neuron-residual-calibration.ts
|
|
6898
|
-
import { z as
|
|
6899
|
-
var Id42 =
|
|
6900
|
-
var Hash46 =
|
|
6901
|
-
var NeuronResidualCalibrationRequestSchema =
|
|
6902
|
-
schemaVersion:
|
|
7013
|
+
import { z as z60 } from "zod";
|
|
7014
|
+
var Id42 = z60.string().trim().min(1).max(500);
|
|
7015
|
+
var Hash46 = z60.string().regex(/^[a-f0-9]{64}$/);
|
|
7016
|
+
var NeuronResidualCalibrationRequestSchema = z60.object({
|
|
7017
|
+
schemaVersion: z60.literal("openpond.neuronResidualCalibrationRequest.v1"),
|
|
6903
7018
|
id: Id42,
|
|
6904
|
-
revision:
|
|
7019
|
+
revision: z60.number().int().positive(),
|
|
6905
7020
|
model: NeuronSteeringModelSchema,
|
|
6906
7021
|
prompt: ActivationReferencePromptSchema,
|
|
6907
|
-
layers:
|
|
6908
|
-
maximumForwardTokenWork:
|
|
6909
|
-
maximumDurationSeconds:
|
|
7022
|
+
layers: z60.array(z60.number().int().nonnegative().max(511)).min(1).max(512),
|
|
7023
|
+
maximumForwardTokenWork: z60.number().int().positive().max(1e6),
|
|
7024
|
+
maximumDurationSeconds: z60.number().finite().positive().max(300)
|
|
6910
7025
|
}).strict().superRefine((value, ctx) => {
|
|
6911
7026
|
if (new Set(value.layers).size !== value.layers.length || value.layers.some((layer) => layer >= value.model.intermediateSizes.length))
|
|
6912
7027
|
ctx.addIssue({ code: "custom", path: ["layers"], message: "Use unique layers inside the exact model." });
|
|
@@ -6915,13 +7030,13 @@ var NeuronResidualCalibrationRequestSchema = z58.object({
|
|
|
6915
7030
|
if (value.prompt.tokenIds.length > value.maximumForwardTokenWork)
|
|
6916
7031
|
ctx.addIssue({ code: "custom", path: ["maximumForwardTokenWork"], message: "The complete unsteered forward exceeds its declared budget." });
|
|
6917
7032
|
});
|
|
6918
|
-
var NeuronResidualCalibrationExportContentSchema =
|
|
6919
|
-
schemaVersion:
|
|
7033
|
+
var NeuronResidualCalibrationExportContentSchema = z60.object({
|
|
7034
|
+
schemaVersion: z60.literal("openpond.neuronResidualCalibrationExport.v1"),
|
|
6920
7035
|
model: NeuronSteeringModelSchema,
|
|
6921
7036
|
prompt: ActivationReferencePromptSchema,
|
|
6922
7037
|
calibration: NeuronResidualCalibrationSchema,
|
|
6923
|
-
runtime:
|
|
6924
|
-
implementation:
|
|
7038
|
+
runtime: z60.object({
|
|
7039
|
+
implementation: z60.literal("torch_dense_serial_calibration_v1"),
|
|
6925
7040
|
implementationHash: Hash46,
|
|
6926
7041
|
torchVersion: Id42,
|
|
6927
7042
|
device: Id42
|
|
@@ -6929,10 +7044,10 @@ var NeuronResidualCalibrationExportContentSchema = z58.object({
|
|
|
6929
7044
|
}).strict();
|
|
6930
7045
|
var NeuronResidualCalibrationExportSchema = NeuronResidualCalibrationExportContentSchema.extend({ contentHash: Hash46 }).strict();
|
|
6931
7046
|
async function parseAndVerifyNeuronResidualCalibrationExport(raw, expected) {
|
|
6932
|
-
const value = NeuronResidualCalibrationExportSchema.parse(raw), { contentHash, ...content } = value;
|
|
7047
|
+
const value = NeuronResidualCalibrationExportSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
6933
7048
|
const calibration = await parseAndVerifyNeuronResidualCalibration(value.calibration, value.model);
|
|
6934
7049
|
const sourceHash = await canonicalSha256(value.prompt), samples = value.prompt.attentionMask.filter(Boolean).length - 1;
|
|
6935
|
-
let mismatch2 =
|
|
7050
|
+
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
7051
|
if (expected) {
|
|
6937
7052
|
const request = NeuronResidualCalibrationRequestSchema.parse(expected);
|
|
6938
7053
|
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 +7057,40 @@ async function parseAndVerifyNeuronResidualCalibrationExport(raw, expected) {
|
|
|
6942
7057
|
}
|
|
6943
7058
|
|
|
6944
7059
|
// 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:
|
|
7060
|
+
import { z as z61 } from "zod";
|
|
7061
|
+
var Id43 = z61.string().trim().min(1).max(500);
|
|
7062
|
+
var Hash47 = z61.string().regex(/^[a-f0-9]{64}$/);
|
|
7063
|
+
var Name2 = z61.string().trim().min(1).max(200);
|
|
7064
|
+
var Timestamp7 = z61.iso.datetime();
|
|
7065
|
+
var NeuronCalibrationRecordContentSchema = z61.object({
|
|
7066
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationRecord.v1"),
|
|
6952
7067
|
teamId: Id43,
|
|
6953
7068
|
ownerUserId: Id43,
|
|
6954
7069
|
projectId: Id43.nullable(),
|
|
6955
7070
|
name: Name2,
|
|
6956
7071
|
artifact: NeuronResidualCalibrationExportSchema,
|
|
6957
|
-
revision:
|
|
6958
|
-
archived:
|
|
7072
|
+
revision: z61.number().int().positive(),
|
|
7073
|
+
archived: z61.boolean(),
|
|
6959
7074
|
createdAt: Timestamp7,
|
|
6960
7075
|
updatedAt: Timestamp7
|
|
6961
7076
|
}).strict();
|
|
6962
7077
|
var NeuronCalibrationRecordSchema = NeuronCalibrationRecordContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
6963
|
-
var NeuronCalibrationImportRequestSchema =
|
|
7078
|
+
var NeuronCalibrationImportRequestSchema = z61.object({
|
|
6964
7079
|
teamId: Id43,
|
|
6965
7080
|
operationId: Id43,
|
|
6966
7081
|
projectId: Id43.nullable(),
|
|
6967
7082
|
name: Name2,
|
|
6968
7083
|
artifact: NeuronResidualCalibrationExportSchema
|
|
6969
7084
|
}).strict();
|
|
6970
|
-
var NeuronCalibrationReadQuerySchema =
|
|
6971
|
-
var NeuronCalibrationArchiveRequestSchema =
|
|
7085
|
+
var NeuronCalibrationReadQuerySchema = z61.object({ teamId: Id43 }).strict();
|
|
7086
|
+
var NeuronCalibrationArchiveRequestSchema = z61.object({
|
|
6972
7087
|
teamId: Id43,
|
|
6973
7088
|
operationId: Id43,
|
|
6974
|
-
expectedRevision:
|
|
7089
|
+
expectedRevision: z61.number().int().positive(),
|
|
6975
7090
|
contentHash: Hash47
|
|
6976
7091
|
}).strict();
|
|
6977
|
-
var NeuronCalibrationReceiptContentSchema =
|
|
6978
|
-
schemaVersion:
|
|
7092
|
+
var NeuronCalibrationReceiptContentSchema = z61.object({
|
|
7093
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationReceipt.v1"),
|
|
6979
7094
|
teamId: Id43,
|
|
6980
7095
|
actorId: Id43,
|
|
6981
7096
|
operationId: Id43,
|
|
@@ -6983,14 +7098,14 @@ var NeuronCalibrationReceiptContentSchema = z59.object({
|
|
|
6983
7098
|
record: NeuronCalibrationRecordSchema
|
|
6984
7099
|
}).strict();
|
|
6985
7100
|
var NeuronCalibrationReceiptSchema = NeuronCalibrationReceiptContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
6986
|
-
var NeuronCalibrationListQuerySchema =
|
|
7101
|
+
var NeuronCalibrationListQuerySchema = z61.object({
|
|
6987
7102
|
projectId: Id43.optional(),
|
|
6988
7103
|
modelHash: Hash47.optional(),
|
|
6989
|
-
archived:
|
|
6990
|
-
limit:
|
|
6991
|
-
cursor:
|
|
7104
|
+
archived: z61.boolean().default(false),
|
|
7105
|
+
limit: z61.number().int().min(1).max(100).default(25),
|
|
7106
|
+
cursor: z61.string().min(1).max(2048).optional()
|
|
6992
7107
|
}).strict();
|
|
6993
|
-
var NeuronCalibrationSummarySchema =
|
|
7108
|
+
var NeuronCalibrationSummarySchema = z61.object({
|
|
6994
7109
|
reference: NeuronSteeringReferenceSchema,
|
|
6995
7110
|
teamId: Id43,
|
|
6996
7111
|
ownerUserId: Id43,
|
|
@@ -6998,36 +7113,36 @@ var NeuronCalibrationSummarySchema = z59.object({
|
|
|
6998
7113
|
name: Name2,
|
|
6999
7114
|
exportHash: Hash47,
|
|
7000
7115
|
modelHash: Hash47,
|
|
7001
|
-
source:
|
|
7116
|
+
source: z61.object({ id: Id43, contentHash: Hash47 }).strict(),
|
|
7002
7117
|
implementationHash: Hash47,
|
|
7003
|
-
layerCount:
|
|
7004
|
-
revision:
|
|
7005
|
-
archived:
|
|
7118
|
+
layerCount: z61.number().int().min(1).max(512),
|
|
7119
|
+
revision: z61.number().int().positive(),
|
|
7120
|
+
archived: z61.boolean(),
|
|
7006
7121
|
createdAt: Timestamp7,
|
|
7007
7122
|
updatedAt: Timestamp7
|
|
7008
7123
|
}).strict();
|
|
7009
|
-
var NeuronCalibrationPageContentSchema =
|
|
7010
|
-
schemaVersion:
|
|
7124
|
+
var NeuronCalibrationPageContentSchema = z61.object({
|
|
7125
|
+
schemaVersion: z61.literal("openpond.neuronCalibrationPage.v1"),
|
|
7011
7126
|
teamId: Id43,
|
|
7012
7127
|
ownerUserId: Id43,
|
|
7013
7128
|
query: NeuronCalibrationListQuerySchema,
|
|
7014
|
-
items:
|
|
7015
|
-
nextCursor:
|
|
7129
|
+
items: z61.array(NeuronCalibrationSummarySchema).max(100),
|
|
7130
|
+
nextCursor: z61.string().min(1).max(2048).nullable()
|
|
7016
7131
|
}).strict();
|
|
7017
7132
|
var NeuronCalibrationPageSchema = NeuronCalibrationPageContentSchema.extend({ contentHash: Hash47 }).strict();
|
|
7018
7133
|
async function parseAndVerifyNeuronCalibrationRecord(raw, expected = {}) {
|
|
7019
|
-
const value = NeuronCalibrationRecordSchema.parse(raw), { contentHash, ...content } = value;
|
|
7134
|
+
const value = NeuronCalibrationRecordSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7020
7135
|
await parseAndVerifyNeuronResidualCalibrationExport(value.artifact);
|
|
7021
|
-
if (
|
|
7136
|
+
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
7137
|
throw new OpenPondProtocolError("neuron_calibration_record_mismatch", "The original calibration record differs from its artifact or authorized workspace.");
|
|
7023
7138
|
return value;
|
|
7024
7139
|
}
|
|
7025
7140
|
async function parseAndVerifyNeuronCalibrationReceipt(raw, request, id) {
|
|
7026
|
-
const value = NeuronCalibrationReceiptSchema.parse(raw), { contentHash, ...content } = value;
|
|
7141
|
+
const value = NeuronCalibrationReceiptSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7027
7142
|
const importing = "artifact" in request;
|
|
7028
7143
|
const parsed = importing ? NeuronCalibrationImportRequestSchema.parse(request) : NeuronCalibrationArchiveRequestSchema.parse(request);
|
|
7029
7144
|
await parseAndVerifyNeuronCalibrationRecord(value.record, { teamId: parsed.teamId, ownerUserId: value.actorId, id });
|
|
7030
|
-
if (
|
|
7145
|
+
if (contentHash2 !== await canonicalSha256(content) || value.teamId !== parsed.teamId || value.operationId !== parsed.operationId || value.requestHash !== await canonicalSha256(importing ? parsed : { id, request: parsed }))
|
|
7031
7146
|
throw new OpenPondProtocolError("neuron_calibration_receipt_mismatch", "Retry the original calibration custody command.");
|
|
7032
7147
|
if ("artifact" in parsed) {
|
|
7033
7148
|
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 +7176,8 @@ function createNeuronCalibrationClient(request) {
|
|
|
7061
7176
|
async listNeuronCalibrations(teamId, raw = {}) {
|
|
7062
7177
|
const scope2 = Id43.parse(teamId), query = Object.fromEntries(Object.entries(NeuronCalibrationListQuerySchema.parse(raw)).filter(([, value]) => value !== void 0)), params5 = new URLSearchParams({ teamId: scope2 });
|
|
7063
7178
|
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) ||
|
|
7179
|
+
const page = NeuronCalibrationPageSchema.parse(await request(`/v1/training/neuron-calibrations?${params5}`)), { contentHash: contentHash2, ...content } = page;
|
|
7180
|
+
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
7181
|
throw new OpenPondProtocolError("neuron_calibration_page_mismatch", "Refresh calibration history in its original workspace.");
|
|
7067
7182
|
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
7183
|
throw new OpenPondProtocolError("neuron_calibration_page_mismatch", "Calibration history returned a different creator or source scope.");
|
|
@@ -7185,64 +7300,64 @@ async function verifyAndCompareActivationReferenceResult(request, raw, reference
|
|
|
7185
7300
|
}
|
|
7186
7301
|
|
|
7187
7302
|
// src/modification-recordings.ts
|
|
7188
|
-
import { z as
|
|
7189
|
-
var Id44 =
|
|
7190
|
-
var Hash48 =
|
|
7303
|
+
import { z as z62 } from "zod";
|
|
7304
|
+
var Id44 = z62.string().trim().min(1).max(240);
|
|
7305
|
+
var Hash48 = z62.string().regex(/^[a-f0-9]{64}$/);
|
|
7191
7306
|
var MODIFICATION_RECORDING_MAX_BYTES = 8388608;
|
|
7192
|
-
var ModificationRecordingRequestSchema =
|
|
7193
|
-
schemaVersion:
|
|
7307
|
+
var ModificationRecordingRequestSchema = z62.object({
|
|
7308
|
+
schemaVersion: z62.literal("openpond.modificationRecordingRequest.v1"),
|
|
7194
7309
|
teamId: Id44,
|
|
7195
7310
|
operationId: Id44,
|
|
7196
|
-
name:
|
|
7311
|
+
name: z62.string().trim().min(1).max(500),
|
|
7197
7312
|
projectId: Id44.nullable(),
|
|
7198
7313
|
method: ModelModificationMethodSchema,
|
|
7199
7314
|
request: ActivationReferenceRequestSchema,
|
|
7200
7315
|
result: ActivationReferenceResultSchema
|
|
7201
7316
|
}).strict();
|
|
7202
|
-
var ModificationRecordingContentSchema =
|
|
7203
|
-
schemaVersion:
|
|
7317
|
+
var ModificationRecordingContentSchema = z62.object({
|
|
7318
|
+
schemaVersion: z62.literal("openpond.modificationRecording.v1"),
|
|
7204
7319
|
id: Id44,
|
|
7205
7320
|
teamId: Id44,
|
|
7206
7321
|
actorId: Id44,
|
|
7207
7322
|
operationId: Id44,
|
|
7208
7323
|
commandHash: Hash48,
|
|
7209
|
-
name:
|
|
7324
|
+
name: z62.string().trim().min(1).max(500),
|
|
7210
7325
|
projectId: Id44.nullable(),
|
|
7211
7326
|
method: ModelModificationMethodSchema,
|
|
7212
7327
|
accountScopeHash: Hash48,
|
|
7213
|
-
custody:
|
|
7214
|
-
provenance:
|
|
7215
|
-
measurementAttestation:
|
|
7328
|
+
custody: z62.literal("local"),
|
|
7329
|
+
provenance: z62.literal("external_observation"),
|
|
7330
|
+
measurementAttestation: z62.literal("unattested"),
|
|
7216
7331
|
model: ActivationReferenceRequestSchema.shape.model,
|
|
7217
7332
|
inputHash: Hash48,
|
|
7218
7333
|
resultHash: Hash48,
|
|
7219
|
-
artifact:
|
|
7220
|
-
counts:
|
|
7221
|
-
prompts:
|
|
7222
|
-
variants:
|
|
7223
|
-
outcomes:
|
|
7224
|
-
captures:
|
|
7334
|
+
artifact: z62.object({ contentHash: Hash48, sizeBytes: z62.number().int().positive().max(MODIFICATION_RECORDING_MAX_BYTES) }).strict(),
|
|
7335
|
+
counts: z62.object({
|
|
7336
|
+
prompts: z62.number().int().positive().max(8),
|
|
7337
|
+
variants: z62.number().int().positive().max(17),
|
|
7338
|
+
outcomes: z62.number().int().positive().max(136),
|
|
7339
|
+
captures: z62.number().int().nonnegative().max(32768)
|
|
7225
7340
|
}).strict(),
|
|
7226
|
-
createdAt:
|
|
7341
|
+
createdAt: z62.iso.datetime()
|
|
7227
7342
|
}).strict();
|
|
7228
7343
|
var ModificationRecordingSchema = ModificationRecordingContentSchema.extend({ contentHash: Hash48 }).strict();
|
|
7229
|
-
var ModificationRecordingDocumentSchema =
|
|
7230
|
-
var ModificationRecordingReadSchema =
|
|
7231
|
-
var ModificationRecordingReadQuerySchema =
|
|
7232
|
-
var ModificationRecordingListQuerySchema =
|
|
7344
|
+
var ModificationRecordingDocumentSchema = z62.object({ request: ActivationReferenceRequestSchema, result: ActivationReferenceResultSchema }).strict();
|
|
7345
|
+
var ModificationRecordingReadSchema = z62.object({ recording: ModificationRecordingSchema, document: ModificationRecordingDocumentSchema }).strict();
|
|
7346
|
+
var ModificationRecordingReadQuerySchema = z62.object({ teamId: Id44 }).strict();
|
|
7347
|
+
var ModificationRecordingListQuerySchema = z62.object({
|
|
7233
7348
|
teamId: Id44,
|
|
7234
7349
|
projectId: Id44.optional(),
|
|
7235
|
-
search:
|
|
7236
|
-
cursor:
|
|
7237
|
-
limit:
|
|
7350
|
+
search: z62.string().trim().max(1e3).optional(),
|
|
7351
|
+
cursor: z62.string().min(1).max(2e3).optional(),
|
|
7352
|
+
limit: z62.number().int().min(1).max(100).default(30)
|
|
7238
7353
|
}).strict();
|
|
7239
|
-
var ModificationRecordingPageSchema =
|
|
7354
|
+
var ModificationRecordingPageSchema = z62.object({
|
|
7240
7355
|
teamId: Id44,
|
|
7241
7356
|
actorId: Id44,
|
|
7242
7357
|
accountScopeHash: Hash48,
|
|
7243
7358
|
projectId: Id44.nullable(),
|
|
7244
|
-
items:
|
|
7245
|
-
nextCursor:
|
|
7359
|
+
items: z62.array(ModificationRecordingSchema).max(100),
|
|
7360
|
+
nextCursor: z62.string().min(1).max(2e3).nullable()
|
|
7246
7361
|
}).strict();
|
|
7247
7362
|
async function verifyModificationRecordingRequest(raw) {
|
|
7248
7363
|
const value = ModificationRecordingRequestSchema.parse(raw);
|
|
@@ -7256,8 +7371,8 @@ async function verifyModificationRecordingRequest(raw) {
|
|
|
7256
7371
|
return value;
|
|
7257
7372
|
}
|
|
7258
7373
|
async function verifyModificationRecording(raw, teamId, actorId) {
|
|
7259
|
-
const value = ModificationRecordingSchema.parse(raw), { contentHash, ...content } = value;
|
|
7260
|
-
if (
|
|
7374
|
+
const value = ModificationRecordingSchema.parse(raw), { contentHash: contentHash2, ...content } = value;
|
|
7375
|
+
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
7376
|
throw new OpenPondProtocolError("modification_recording_scope_mismatch", "The retained recording differs from its owner or immutable metadata.");
|
|
7262
7377
|
return value;
|
|
7263
7378
|
}
|
|
@@ -7313,37 +7428,37 @@ function createModificationRecordingsClient(request) {
|
|
|
7313
7428
|
}
|
|
7314
7429
|
|
|
7315
7430
|
// 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:
|
|
7431
|
+
import { z as z63 } from "zod";
|
|
7432
|
+
var OpaqueIdentifier = z63.string().min(1).max(191).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/);
|
|
7433
|
+
var TrainingHardwareSpecificationSchema = z63.object({
|
|
7434
|
+
id: z63.string().trim().min(1).max(256),
|
|
7435
|
+
name: z63.string().trim().min(1).max(256),
|
|
7436
|
+
manufacturer: z63.string().trim().min(1).max(100),
|
|
7437
|
+
memoryGb: z63.number().int().positive(),
|
|
7438
|
+
secureCloud: z63.boolean(),
|
|
7439
|
+
communityCloud: z63.boolean(),
|
|
7440
|
+
maximumPerPod: z63.object({
|
|
7441
|
+
secure: z63.number().int().nonnegative(),
|
|
7442
|
+
community: z63.number().int().nonnegative()
|
|
7328
7443
|
}).strict()
|
|
7329
7444
|
}).strict();
|
|
7330
|
-
var TrainingHardwareInventorySchema =
|
|
7331
|
-
schemaVersion:
|
|
7445
|
+
var TrainingHardwareInventorySchema = z63.object({
|
|
7446
|
+
schemaVersion: z63.literal("openpond.trainingHardwareInventory.v1"),
|
|
7332
7447
|
provider: OpaqueIdentifier,
|
|
7333
7448
|
source: OpaqueIdentifier,
|
|
7334
|
-
version:
|
|
7335
|
-
observedAt:
|
|
7336
|
-
refreshAfter:
|
|
7337
|
-
hardware:
|
|
7449
|
+
version: z63.string().regex(/^[a-f0-9]{64}$/),
|
|
7450
|
+
observedAt: z63.iso.datetime(),
|
|
7451
|
+
refreshAfter: z63.iso.datetime(),
|
|
7452
|
+
hardware: z63.array(TrainingHardwareSpecificationSchema).max(1e3)
|
|
7338
7453
|
}).strict();
|
|
7339
|
-
var TrainingHardwareCatalogSchema =
|
|
7340
|
-
schemaVersion:
|
|
7454
|
+
var TrainingHardwareCatalogSchema = z63.object({
|
|
7455
|
+
schemaVersion: z63.literal("openpond.trainingHardwareCatalog.v1"),
|
|
7341
7456
|
inventory: TrainingHardwareInventorySchema,
|
|
7342
|
-
workerImageDigest:
|
|
7343
|
-
eligibility:
|
|
7344
|
-
gpuTypeId:
|
|
7345
|
-
status:
|
|
7346
|
-
reason:
|
|
7457
|
+
workerImageDigest: z63.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
7458
|
+
eligibility: z63.array(z63.object({
|
|
7459
|
+
gpuTypeId: z63.string().min(1).max(256),
|
|
7460
|
+
status: z63.enum(["requires_live_workload_check", "not_admitted"]),
|
|
7461
|
+
reason: z63.enum(["candidate_for_current_runtime", "gpu_type_not_enabled", "secure_pods_unavailable", "insufficient_memory"])
|
|
7347
7462
|
}).strict()).max(1e3)
|
|
7348
7463
|
}).strict();
|
|
7349
7464
|
async function parseAndVerifyTrainingHardwareInventory(raw) {
|
|
@@ -7370,12 +7485,12 @@ function createTrainingHardwareCatalogClient(request) {
|
|
|
7370
7485
|
}
|
|
7371
7486
|
|
|
7372
7487
|
// src/training-harness-sources.ts
|
|
7373
|
-
import { z as
|
|
7374
|
-
var TrainingHarnessSourcePublicationSchema =
|
|
7375
|
-
schemaVersion:
|
|
7488
|
+
import { z as z64 } from "zod";
|
|
7489
|
+
var TrainingHarnessSourcePublicationSchema = z64.object({
|
|
7490
|
+
schemaVersion: z64.literal("openpond.trainingHarnessSourcePublication.v1"),
|
|
7376
7491
|
harnessRelease: ImmutableReleaseRefSchema,
|
|
7377
|
-
sourcePackageHash:
|
|
7378
|
-
sizeBytes:
|
|
7492
|
+
sourcePackageHash: z64.string().regex(/^[a-f0-9]{64}$/),
|
|
7493
|
+
sizeBytes: z64.number().int().positive().max(TRAINING_INPUT_ARTIFACT_MAX_BYTES)
|
|
7379
7494
|
}).strict();
|
|
7380
7495
|
function createTrainingHarnessSourceClient(request) {
|
|
7381
7496
|
const route = (reference) => {
|
|
@@ -7408,28 +7523,28 @@ function validateSource(value, reference) {
|
|
|
7408
7523
|
}
|
|
7409
7524
|
|
|
7410
7525
|
// src/training-candidate-decisions.ts
|
|
7411
|
-
import { z as
|
|
7412
|
-
var IdSchema = /* @__PURE__ */ (() =>
|
|
7413
|
-
var HashSchema = /* @__PURE__ */ (() =>
|
|
7414
|
-
var TrainingCandidateDecisionRequestSchema = /* @__PURE__ */ (() =>
|
|
7415
|
-
schemaVersion:
|
|
7526
|
+
import { z as z65 } from "zod";
|
|
7527
|
+
var IdSchema = /* @__PURE__ */ (() => z65.string().trim().min(1).max(500))();
|
|
7528
|
+
var HashSchema = /* @__PURE__ */ (() => z65.string().regex(/^[a-f0-9]{64}$/))();
|
|
7529
|
+
var TrainingCandidateDecisionRequestSchema = /* @__PURE__ */ (() => z65.object({
|
|
7530
|
+
schemaVersion: z65.literal("openpond.trainingCandidateDecisionRequest.v1"),
|
|
7416
7531
|
teamId: IdSchema,
|
|
7417
7532
|
jobId: IdSchema,
|
|
7418
7533
|
artifact: ModelProjectImmutableRefSchema,
|
|
7419
7534
|
evaluation: ModelProjectImmutableRefSchema,
|
|
7420
7535
|
executionReceipt: ModelProjectImmutableRefSchema,
|
|
7421
|
-
decision:
|
|
7422
|
-
reason:
|
|
7536
|
+
decision: z65.enum(["accepted", "rejected"]),
|
|
7537
|
+
reason: z65.string().trim().min(1).max(5e3),
|
|
7423
7538
|
idempotencyKey: IdSchema,
|
|
7424
7539
|
expectedDecision: ModelProjectImmutableRefSchema.nullable()
|
|
7425
7540
|
}).strict())();
|
|
7426
|
-
var TrainingCandidateDecisionSchema = /* @__PURE__ */ (() =>
|
|
7427
|
-
schemaVersion:
|
|
7541
|
+
var TrainingCandidateDecisionSchema = /* @__PURE__ */ (() => z65.object({
|
|
7542
|
+
schemaVersion: z65.literal("openpond.trainingCandidateDecision.v1"),
|
|
7428
7543
|
id: IdSchema,
|
|
7429
7544
|
request: TrainingCandidateDecisionRequestSchema,
|
|
7430
|
-
revision:
|
|
7431
|
-
actor:
|
|
7432
|
-
decidedAt:
|
|
7545
|
+
revision: z65.number().int().positive(),
|
|
7546
|
+
actor: z65.object({ userId: IdSchema, kind: z65.enum(["user", "api_key", "agent_delegate"]), id: IdSchema }).strict(),
|
|
7547
|
+
decidedAt: z65.string().datetime({ offset: true }),
|
|
7433
7548
|
contentHash: HashSchema
|
|
7434
7549
|
}).strict().superRefine((value, context) => {
|
|
7435
7550
|
if (value.revision === 1 !== (value.request.expectedDecision === null)) {
|
|
@@ -7466,7 +7581,7 @@ function createTrainingCandidateDecisionClient(request) {
|
|
|
7466
7581
|
IdSchema.parse(target.teamId);
|
|
7467
7582
|
const reference = options.decision ? ModelProjectImmutableRefSchema.parse(options.decision) : void 0;
|
|
7468
7583
|
const query = reference ? `?decisionId=${encodeURIComponent(reference.id)}` : "";
|
|
7469
|
-
const response =
|
|
7584
|
+
const response = z65.object({ decision: z65.unknown().nullable() }).strict().parse(await request(`${route(target)}${query}`));
|
|
7470
7585
|
if (response.decision === null && !reference) return null;
|
|
7471
7586
|
const decision = await parseAndVerifyTrainingCandidateDecision(response.decision, target);
|
|
7472
7587
|
if (reference && (decision.id !== reference.id || decision.contentHash !== reference.contentHash)) {
|
|
@@ -7483,38 +7598,38 @@ function createTrainingCandidateDecisionClient(request) {
|
|
|
7483
7598
|
}
|
|
7484
7599
|
|
|
7485
7600
|
// src/training-evaluation-results.ts
|
|
7486
|
-
import { z as
|
|
7487
|
-
var IdSchema2 = /* @__PURE__ */ (() =>
|
|
7488
|
-
var HashSchema2 = /* @__PURE__ */ (() =>
|
|
7489
|
-
var TrainingEvaluationTaskResultSchema = /* @__PURE__ */ (() =>
|
|
7601
|
+
import { z as z66 } from "zod";
|
|
7602
|
+
var IdSchema2 = /* @__PURE__ */ (() => z66.string().trim().min(1).max(500))();
|
|
7603
|
+
var HashSchema2 = /* @__PURE__ */ (() => z66.string().regex(/^[a-f0-9]{64}$/))();
|
|
7604
|
+
var TrainingEvaluationTaskResultSchema = /* @__PURE__ */ (() => z66.object({
|
|
7490
7605
|
taskId: IdSchema2,
|
|
7491
7606
|
taskSha256: HashSchema2,
|
|
7492
7607
|
resultSha256: HashSchema2,
|
|
7493
|
-
input:
|
|
7494
|
-
instruction:
|
|
7495
|
-
context:
|
|
7608
|
+
input: z66.object({
|
|
7609
|
+
instruction: z66.string().max(1e6),
|
|
7610
|
+
context: z66.record(z66.string(), z66.unknown())
|
|
7496
7611
|
}).strict(),
|
|
7497
|
-
output:
|
|
7612
|
+
output: z66.string().max(1e6),
|
|
7498
7613
|
outputSha256: HashSchema2,
|
|
7499
|
-
score:
|
|
7500
|
-
evidence:
|
|
7501
|
-
kind:
|
|
7614
|
+
score: z66.number().finite().min(0).max(1),
|
|
7615
|
+
evidence: z66.object({
|
|
7616
|
+
kind: z66.enum(["worker_command", "hosted_trace", "local_trace"]),
|
|
7502
7617
|
id: IdSchema2
|
|
7503
7618
|
}).strict()
|
|
7504
7619
|
}).strict())();
|
|
7505
|
-
var TrainingEvaluationTaskPageSchema = /* @__PURE__ */ (() =>
|
|
7506
|
-
schemaVersion:
|
|
7620
|
+
var TrainingEvaluationTaskPageSchema = /* @__PURE__ */ (() => z66.object({
|
|
7621
|
+
schemaVersion: z66.literal("openpond.trainingEvaluationTaskPage.v1"),
|
|
7507
7622
|
jobId: IdSchema2,
|
|
7508
7623
|
teamId: IdSchema2,
|
|
7509
7624
|
evaluation: ModelProjectImmutableRefSchema,
|
|
7510
|
-
kind:
|
|
7511
|
-
policyVersion:
|
|
7625
|
+
kind: z66.enum(["baseline", "candidate"]),
|
|
7626
|
+
policyVersion: z66.number().int().nonnegative(),
|
|
7512
7627
|
taskset: ModelProjectVersionedRefSchema,
|
|
7513
7628
|
panelSha256: HashSchema2,
|
|
7514
|
-
offset:
|
|
7515
|
-
total:
|
|
7516
|
-
tasks:
|
|
7517
|
-
nextCursor:
|
|
7629
|
+
offset: z66.number().int().nonnegative(),
|
|
7630
|
+
total: z66.number().int().min(1).max(1e4),
|
|
7631
|
+
tasks: z66.array(TrainingEvaluationTaskResultSchema).min(1).max(100),
|
|
7632
|
+
nextCursor: z66.string().regex(/^[1-9]\d*$/).nullable(),
|
|
7518
7633
|
contentHash: HashSchema2
|
|
7519
7634
|
}).strict().superRefine((page, context) => {
|
|
7520
7635
|
const end = page.offset + page.tasks.length;
|
|
@@ -7720,13 +7835,14 @@ async function experimentStartingModelFromSteeringVersion(resolved, options = {}
|
|
|
7720
7835
|
}
|
|
7721
7836
|
|
|
7722
7837
|
// src/training.ts
|
|
7723
|
-
var IdSchema3 =
|
|
7838
|
+
var IdSchema3 = z67.string().trim().min(1).max(500);
|
|
7724
7839
|
function createTrainingClient(input) {
|
|
7725
7840
|
const request = createTrainingRequest(input);
|
|
7726
7841
|
return {
|
|
7727
7842
|
postTraining: createPostTrainingClient({ request }),
|
|
7728
7843
|
...createTrainingPreparationClient(request),
|
|
7729
7844
|
...createTrainingExperimentSetupClient(request),
|
|
7845
|
+
...createTrainingExperimentLearningClient(request),
|
|
7730
7846
|
...createTrainingEstimateClient(request),
|
|
7731
7847
|
...createTrainingFundingClient(request),
|
|
7732
7848
|
...createDatasetTrainingReviewClient(request),
|
|
@@ -7795,10 +7911,10 @@ function createTrainingClient(input) {
|
|
|
7795
7911
|
parameters.set("modelProjectId", IdSchema3.parse(options.modelProjectId));
|
|
7796
7912
|
}
|
|
7797
7913
|
if (options.cursor) {
|
|
7798
|
-
parameters.set("cursor",
|
|
7914
|
+
parameters.set("cursor", z67.string().trim().min(1).max(2e3).parse(options.cursor));
|
|
7799
7915
|
}
|
|
7800
7916
|
if (options.limit !== void 0) {
|
|
7801
|
-
parameters.set("limit", String(
|
|
7917
|
+
parameters.set("limit", String(z67.number().int().min(1).max(1e3).parse(options.limit)));
|
|
7802
7918
|
}
|
|
7803
7919
|
const query = parameters.size > 0 ? `?${parameters.toString()}` : "";
|
|
7804
7920
|
return TrainingJobPageSchema.parse(await request(`/v1/training/jobs${query}`));
|
|
@@ -7848,7 +7964,7 @@ function createTrainingClient(input) {
|
|
|
7848
7964
|
), "job"));
|
|
7849
7965
|
},
|
|
7850
7966
|
async events(jobId) {
|
|
7851
|
-
return
|
|
7967
|
+
return z67.array(TrainingJobEventSchema).parse(
|
|
7852
7968
|
unwrapObject(
|
|
7853
7969
|
await request(`/v1/training/jobs/${encodeURIComponent(IdSchema3.parse(jobId))}/events`),
|
|
7854
7970
|
"events"
|
|
@@ -7864,11 +7980,11 @@ function createTrainingClient(input) {
|
|
|
7864
7980
|
const id = IdSchema3.parse(jobId);
|
|
7865
7981
|
const reference = ModelProjectImmutableRefSchema.parse(evaluation);
|
|
7866
7982
|
const parameters = new URLSearchParams();
|
|
7867
|
-
const cursor = options.cursor === void 0 ? void 0 :
|
|
7868
|
-
const offset = cursor === void 0 ? 0 :
|
|
7983
|
+
const cursor = options.cursor === void 0 ? void 0 : z67.string().regex(/^[1-9]\d*$/).parse(options.cursor);
|
|
7984
|
+
const offset = cursor === void 0 ? 0 : z67.number().int().min(1).max(9999).parse(Number(cursor));
|
|
7869
7985
|
if (cursor !== void 0) parameters.set("cursor", cursor);
|
|
7870
7986
|
if (options.limit !== void 0)
|
|
7871
|
-
parameters.set("limit", String(
|
|
7987
|
+
parameters.set("limit", String(z67.number().int().min(1).max(100).parse(options.limit)));
|
|
7872
7988
|
const query = parameters.size ? `?${parameters.toString()}` : "";
|
|
7873
7989
|
return parseAndVerifyTrainingEvaluationTaskPage(
|
|
7874
7990
|
await request(
|
|
@@ -7878,7 +7994,7 @@ function createTrainingClient(input) {
|
|
|
7878
7994
|
);
|
|
7879
7995
|
},
|
|
7880
7996
|
async logs(jobId) {
|
|
7881
|
-
return
|
|
7997
|
+
return z67.array(TrainingJobLogSchema).max(1e5).parse(
|
|
7882
7998
|
unwrapObject(
|
|
7883
7999
|
await request(`/v1/training/jobs/${encodeURIComponent(IdSchema3.parse(jobId))}/logs`),
|
|
7884
8000
|
"logs"
|
|
@@ -8332,6 +8448,9 @@ export {
|
|
|
8332
8448
|
TrainingExecutionSummarySchema,
|
|
8333
8449
|
TrainingExperimentFormDraftSchema,
|
|
8334
8450
|
TrainingExperimentInputsPageSchema,
|
|
8451
|
+
TrainingExperimentLearningIntentSchema,
|
|
8452
|
+
TrainingExperimentLearningReceiptSchema,
|
|
8453
|
+
TrainingExperimentLearningRequestSchema,
|
|
8335
8454
|
TrainingExperimentSetupReceiptSchema,
|
|
8336
8455
|
TrainingExperimentSetupRequestSchema,
|
|
8337
8456
|
TrainingFundingDraftRefSchema,
|
|
@@ -8450,6 +8569,7 @@ export {
|
|
|
8450
8569
|
createSteeringProfileClient,
|
|
8451
8570
|
createTrainingCheckpointRecoveryResourceApproval,
|
|
8452
8571
|
createTrainingClient,
|
|
8572
|
+
createTrainingExperimentLearningClient,
|
|
8453
8573
|
createTrainingFundingClient,
|
|
8454
8574
|
createTrainingHardwareCatalogClient,
|
|
8455
8575
|
createTrainingModelSaveClient,
|
|
@@ -8619,6 +8739,12 @@ export {
|
|
|
8619
8739
|
trainingEvaluationTaskPageHash,
|
|
8620
8740
|
trainingExecutionReceiptHash,
|
|
8621
8741
|
trainingExperimentConfigurationIdentity,
|
|
8742
|
+
trainingExperimentInitialLearning,
|
|
8743
|
+
trainingExperimentLearningInputHash,
|
|
8744
|
+
trainingExperimentLearningRequest,
|
|
8745
|
+
trainingExperimentLearningSettings,
|
|
8746
|
+
trainingExperimentSavedConfiguration,
|
|
8747
|
+
trainingExperimentTrainingInputHash,
|
|
8622
8748
|
trainingInputArtifactUploadHash,
|
|
8623
8749
|
trainingJobSubmissionHash,
|
|
8624
8750
|
trainingModelServingState,
|