openpond-sdk 0.5.26 → 0.5.28

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.
Files changed (59) hide show
  1. package/TASKSETS.md +20 -4
  2. package/dist/{chunk-S7I45WJQ.js → chunk-2U54EOXJ.js} +3 -2
  3. package/dist/chunk-2U54EOXJ.js.map +7 -0
  4. package/dist/{chunk-GFVMIDP5.js → chunk-B3CH4V35.js} +318 -18
  5. package/dist/chunk-B3CH4V35.js.map +7 -0
  6. package/dist/{chunk-YVOKMF45.js → chunk-FFRYTXGF.js} +18 -8
  7. package/dist/chunk-FFRYTXGF.js.map +7 -0
  8. package/dist/{chunk-7PCER4VL.js → chunk-O27OEXXB.js} +5 -3
  9. package/dist/{chunk-7PCER4VL.js.map → chunk-O27OEXXB.js.map} +1 -1
  10. package/dist/{chunk-S5UZTXXB.js → chunk-WT7JU2CT.js} +4 -305
  11. package/dist/chunk-WT7JU2CT.js.map +7 -0
  12. package/dist/{chunk-AMBW4UHN.js → chunk-ZIMHPYXL.js} +13 -8
  13. package/dist/{chunk-AMBW4UHN.js.map → chunk-ZIMHPYXL.js.map} +2 -2
  14. package/dist/model-starter-catalog.js +4 -2
  15. package/dist/model-starter-catalog.js.map +1 -1
  16. package/dist/model-starters.js +4 -2
  17. package/dist/model-taskset-authoring.js +1 -1
  18. package/dist/taskset-drafts.js +4 -4
  19. package/dist/taskset-packages.js +214 -52
  20. package/dist/taskset-packages.js.map +4 -4
  21. package/dist/training-bundle.js +6 -5
  22. package/dist/training-bundle.js.map +1 -1
  23. package/dist/types/packages/sdk/src/model-bound-taskset-authoring.d.ts +10 -0
  24. package/dist/types/packages/sdk/src/model-bound-taskset-authoring.d.ts.map +1 -0
  25. package/dist/types/packages/sdk/src/model-ordinary-taskset-reward.d.ts +16 -0
  26. package/dist/types/packages/sdk/src/model-ordinary-taskset-reward.d.ts.map +1 -0
  27. package/dist/types/packages/sdk/src/model-taskset-authoring-contracts.d.ts +1 -0
  28. package/dist/types/packages/sdk/src/model-taskset-authoring-contracts.d.ts.map +1 -1
  29. package/dist/types/packages/sdk/src/model-taskset-authoring.d.ts +1 -0
  30. package/dist/types/packages/sdk/src/model-taskset-authoring.d.ts.map +1 -1
  31. package/dist/types/packages/sdk/src/model-taskset-derivation.d.ts +11 -0
  32. package/dist/types/packages/sdk/src/model-taskset-derivation.d.ts.map +1 -1
  33. package/dist/types/packages/sdk/src/model-training-defaults.d.ts.map +1 -1
  34. package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts +2 -0
  35. package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts.map +1 -1
  36. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +6 -0
  37. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -1
  38. package/dist/types/packages/sdk/src/taskset-draft-document.d.ts +1 -0
  39. package/dist/types/packages/sdk/src/taskset-draft-document.d.ts.map +1 -1
  40. package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts +3 -0
  41. package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts.map +1 -1
  42. package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts.map +1 -1
  43. package/dist/types/packages/sdk/src/taskset-draft-source.d.ts +2 -0
  44. package/dist/types/packages/sdk/src/taskset-draft-source.d.ts.map +1 -1
  45. package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts +2 -0
  46. package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts.map +1 -1
  47. package/dist/types/packages/sdk/src/taskset-package-client.d.ts +3 -0
  48. package/dist/types/packages/sdk/src/taskset-package-client.d.ts.map +1 -1
  49. package/dist/types/packages/sdk/src/taskset-package-contracts.d.ts +2 -0
  50. package/dist/types/packages/sdk/src/taskset-package-contracts.d.ts.map +1 -1
  51. package/dist/types/packages/sdk/src/taskset-package-projection.d.ts +1 -0
  52. package/dist/types/packages/sdk/src/taskset-package-projection.d.ts.map +1 -1
  53. package/dist/types/packages/sdk/src/taskset-packages.d.ts +1 -0
  54. package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-GFVMIDP5.js.map +0 -7
  57. package/dist/chunk-S5UZTXXB.js.map +0 -7
  58. package/dist/chunk-S7I45WJQ.js.map +0 -7
  59. package/dist/chunk-YVOKMF45.js.map +0 -7
package/TASKSETS.md CHANGED
@@ -186,10 +186,26 @@ reseals the environment before publication, while historical revisions keep
186
186
  their original executable files.
187
187
 
188
188
  These pure helpers require the host to persist draft files and commit publication,
189
- Model selection and retry receipts atomically. Bound Reward packages and reviewed
190
- batches use their respective authoring graphs and are rejected by this ordinary
191
- package compiler. Draft persistence, HTTP operations and editor controls are host
192
- integration work.
189
+ Model selection and retry receipts atomically. Bound Reward packages use the same
190
+ draft workflow with `authoringGraph: "bound"` in their retained preparation.
191
+ Pass the original `source` package to `publishModelTasksetDraftPackage` or
192
+ `compileModelTasksetDraftWorkspace` for these drafts. Task edits preserve the
193
+ exact saved Reward, task format and private dependency graph; changing graders
194
+ requires publishing/selecting a Reward through its own editor. Unchanged
195
+ environment execution retains its release. Publication creates an owned revision
196
+ and clears package qualification; it never changes the original source. Reviewed
197
+ batches still require their review/regrading workflow.
198
+
199
+ `bindOrdinaryModelTasksetReward({ owner, source, rewardBinding, rewards, assets })`
200
+ prepares a complete model-owned package when a user selects a saved Reward for an
201
+ ordinary collection. The source must include collection instructions. This keeps
202
+ task envelopes, per-task output contracts, binary files, private context and tools
203
+ intact. Its model resources explicitly declare `instructionMode: "per_task"` so
204
+ task-specific context is preserved independently of the collection instruction.
205
+ The selected Reward's private assets must resolve exactly. Hosts commit the new
206
+ package and Model selection with their CAS and retry receipt, regenerate stale
207
+ recipes, and advance an evaluation selection that referred to the edited source.
208
+ An independently selected evaluation package remains pinned.
193
209
 
194
210
  ## Shared draft documents and compilation
195
211
 
@@ -25,7 +25,8 @@ var ModelTasksetDraftPreparationSchema = z.object({
25
25
  sourceTasksetRef: LearningRevisionRefSchema,
26
26
  tasksetId: IdSchema,
27
27
  tasksetRevision: z.number().int().positive(),
28
- lineage: ModelTasksetAuthoringSchema
28
+ lineage: ModelTasksetAuthoringSchema,
29
+ authoringGraph: z.literal("bound").optional()
29
30
  }).strict();
30
31
  var TasksetDraftFilePathSchema = z.string().min(1).max(1024).refine((value) => !value.includes("\\") && !value.includes(":") && !value.includes("\0") && !value.startsWith("/") && !value.split("/").some((part) => !part || part === "." || part === ".." || part.startsWith(".env")), "Use a relative Taskset file path without environment files.");
31
32
  var TasksetDraftFileInfoSchema = z.object({
@@ -54,4 +55,4 @@ export {
54
55
  TasksetDraftFileSchema,
55
56
  TasksetDraftFileMutationSchema
56
57
  };
57
- //# sourceMappingURL=chunk-S7I45WJQ.js.map
58
+ //# sourceMappingURL=chunk-2U54EOXJ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/model-taskset-authoring-contracts.ts"],
4
+ "sourcesContent": ["import { z } from \"zod\";\nimport { LearningRevisionRefSchema } from \"@openpond/evals/learning\";\n\nconst IdSchema = LearningRevisionRefSchema.shape.id;\nconst HashSchema = z.string().regex(/^[a-f0-9]{64}$/);\nexport const ModelTasksetAuthoringOwnerSchema = z.object({ scopeId: IdSchema, modelId: IdSchema }).strict();\n\n/** Ordinary authoring preserves its own lineage without inventing a Reward\n * binding or replacing an admitted learning graph. Hosts authorize the owner. */\nexport const ModelTasksetAuthoringSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetAuthoring.v1\"),\n owner: ModelTasksetAuthoringOwnerSchema,\n root: LearningRevisionRefSchema,\n parent: LearningRevisionRefSchema,\n}).strict();\n\nexport const ModelTasksetDraftRequestSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetDraftRequest.v1\"),\n operationId: IdSchema,\n modelId: IdSchema,\n expectedModelRevision: z.number().int().positive(),\n sourcePackageHash: HashSchema,\n}).strict();\nexport type ModelTasksetDraftRequest = z.infer<typeof ModelTasksetDraftRequestSchema>;\n\n/** Persist this preparation before materializing the editable workspace. */\nexport const ModelTasksetDraftPreparationSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetDraftPreparation.v1\"),\n draftId: IdSchema,\n requestHash: HashSchema,\n sourcePackageHash: HashSchema,\n sourceTasksetRef: LearningRevisionRefSchema,\n tasksetId: IdSchema,\n tasksetRevision: z.number().int().positive(),\n lineage: ModelTasksetAuthoringSchema,\n authoringGraph: z.literal(\"bound\").optional(),\n}).strict();\nexport type ModelTasksetDraftPreparation = z.infer<typeof ModelTasksetDraftPreparationSchema>;\n\nexport const TasksetDraftFilePathSchema = z.string().min(1).max(1024).refine(value =>\n !value.includes(\"\\\\\") && !value.includes(\":\") && !value.includes(\"\\0\") && !value.startsWith(\"/\")\n && !value.split(\"/\").some(part => !part || part === \".\" || part === \"..\" || part.startsWith(\".env\")), \"Use a relative Taskset file path without environment files.\");\nexport const TasksetDraftFileInfoSchema = z.object({\n path: TasksetDraftFilePathSchema,\n sizeBytes: z.number().int().nonnegative(),\n writable: z.boolean(),\n}).strict();\nexport const TasksetDraftFileContentSchema = z.object({ encoding: z.enum([\"utf8\", \"base64\"]), data: z.string().max(8_000_000) }).strict();\nexport const TasksetDraftFileSchema = TasksetDraftFileInfoSchema.extend({ contentHash: HashSchema, content: TasksetDraftFileContentSchema }).strict();\nexport const TasksetDraftFileMutationSchema = z.object({\n draftId: IdSchema,\n expectedDraftRevision: z.number().int().positive(),\n path: TasksetDraftFilePathSchema,\n expectedFileHash: HashSchema.nullable(),\n content: TasksetDraftFileContentSchema.nullable(),\n}).strict();\nexport type TasksetDraftFileInfo = z.infer<typeof TasksetDraftFileInfoSchema>;\nexport type TasksetDraftFile = z.infer<typeof TasksetDraftFileSchema>;\nexport type TasksetDraftFileMutation = z.infer<typeof TasksetDraftFileMutationSchema>;\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS;AAClB,SAAS,iCAAiC;AAE1C,IAAM,WAAW,0BAA0B,MAAM;AACjD,IAAM,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB;AAC7C,IAAM,mCAAmC,EAAE,OAAO,EAAE,SAAS,UAAU,SAAS,SAAS,CAAC,EAAE,OAAO;AAInG,IAAM,8BAA8B,EAAE,OAAO;AAAA,EAClD,eAAe,EAAE,QAAQ,mCAAmC;AAAA,EAC5D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AACV,CAAC,EAAE,OAAO;AAEH,IAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,eAAe,EAAE,QAAQ,sCAAsC;AAAA,EAC/D,aAAa;AAAA,EACb,SAAS;AAAA,EACT,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACjD,mBAAmB;AACrB,CAAC,EAAE,OAAO;AAIH,IAAM,qCAAqC,EAAE,OAAO;AAAA,EACzD,eAAe,EAAE,QAAQ,0CAA0C;AAAA,EACnE,SAAS;AAAA,EACT,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC3C,SAAS;AAAA,EACT,gBAAgB,EAAE,QAAQ,OAAO,EAAE,SAAS;AAC9C,CAAC,EAAE,OAAO;AAGH,IAAM,6BAA6B,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,EAAE,OAAO,WAC3E,CAAC,MAAM,SAAS,IAAI,KAAK,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,SAAS,IAAI,KAAK,CAAC,MAAM,WAAW,GAAG,KAC5F,CAAC,MAAM,MAAM,GAAG,EAAE,KAAK,UAAQ,CAAC,QAAQ,SAAS,OAAO,SAAS,QAAQ,KAAK,WAAW,MAAM,CAAC,GAAG,6DAA6D;AAC9J,IAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAAA,EACxC,UAAU,EAAE,QAAQ;AACtB,CAAC,EAAE,OAAO;AACH,IAAM,gCAAgC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,GAAS,EAAE,CAAC,EAAE,OAAO;AACjI,IAAM,yBAAyB,2BAA2B,OAAO,EAAE,aAAa,YAAY,SAAS,8BAA8B,CAAC,EAAE,OAAO;AAC7I,IAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,SAAS;AAAA,EACT,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACjD,MAAM;AAAA,EACN,kBAAkB,WAAW,SAAS;AAAA,EACtC,SAAS,8BAA8B,SAAS;AAClD,CAAC,EAAE,OAAO;",
6
+ "names": []
7
+ }
@@ -1,3 +1,11 @@
1
+ import {
2
+ ModelTasksetAuthoringSchema
3
+ } from "./chunk-2U54EOXJ.js";
4
+ import {
5
+ ImmutableAssetRefSchema,
6
+ contentHash,
7
+ sha256
8
+ } from "./chunk-QUOW6URQ.js";
1
9
  import {
2
10
  ModelProjectVersionedRefSchema,
3
11
  canonicalJson
@@ -25,8 +33,8 @@ var ModelStarterEnvironmentAttemptSchema = /* @__PURE__ */ (() => z.object({
25
33
  function verifyModelStarterEnvironmentAttempt(value, context) {
26
34
  assertBoundedTaskJson(value, 16777216);
27
35
  const result = ModelStarterEnvironmentAttemptSchema.parse(value);
28
- const { contentHash, ...content } = result;
29
- if (sealLearningContent(content).contentHash !== contentHash || result.taskId !== context.taskId || result.snapshot && (!equal(result.snapshot.definition, context.javascript) || result.snapshot.inputHash !== sealLearningContent(context.input).contentHash || result.snapshot.seed !== context.seed || result.snapshot.finalStateHash !== sealLearningContent(result.snapshot.state).contentHash)) throw new Error("Starter environment attempt differs from its admitted task or recorded bytes.");
36
+ const { contentHash: contentHash2, ...content } = result;
37
+ if (sealLearningContent(content).contentHash !== contentHash2 || result.taskId !== context.taskId || result.snapshot && (!equal(result.snapshot.definition, context.javascript) || result.snapshot.inputHash !== sealLearningContent(context.input).contentHash || result.snapshot.seed !== context.seed || result.snapshot.finalStateHash !== sealLearningContent(result.snapshot.state).contentHash)) throw new Error("Starter environment attempt differs from its admitted task or recorded bytes.");
30
38
  return result;
31
39
  }
32
40
  var ModelStarterExecutionSchema = z.object({
@@ -61,8 +69,8 @@ function equal(left, right) {
61
69
  function assertExecutionIntegrity(execution) {
62
70
  assertJavaScriptEnvironmentDefinition(execution.javascript);
63
71
  for (const resource of [execution.environment, execution.verifierSet]) {
64
- const { contentHash, ...content } = resource;
65
- if (sealLearningContent(content).contentHash !== contentHash) throw new Error(`Starter execution resource integrity failed: ${resource.id}.`);
72
+ const { contentHash: contentHash2, ...content } = resource;
73
+ if (sealLearningContent(content).contentHash !== contentHash2) throw new Error(`Starter execution resource integrity failed: ${resource.id}.`);
66
74
  }
67
75
  if (!equal(execution.environment.metadata.javascriptEnvironment, learningRef(execution.javascript))) throw new Error("Starter execution resources differ from its declared task context.");
68
76
  }
@@ -145,13 +153,18 @@ var ModelTasksetPackageSchema = z3.object({
145
153
  rewards: z3.array(RewardReleaseSchema).min(1).max(100),
146
154
  assets: z3.array(LearningTextAssetSchema).max(1e3),
147
155
  executionResources: ModelTasksetExecutionResourcesSchema.optional(),
148
- execution: ModelStarterExecutionSchema.optional()
156
+ execution: ModelStarterExecutionSchema.optional(),
157
+ instructionMode: z3.literal("per_task").optional()
149
158
  }).strict();
150
159
  var same = (left, right) => sealLearningContent3({ value: left }).contentHash === sealLearningContent3({ value: right }).contentHash;
151
160
  var identity = (owner, root) => `model-taskset-${sealLearningContent3({ owner, root }).contentHash}`;
152
161
  function deriveModelTaskset(input) {
162
+ return compileModelTasksetReward({ ...input, source: validateModelTasksetPackage(input.source) });
163
+ }
164
+ function compileModelTasksetReward(input) {
153
165
  const owner = OwnerSchema.parse(input.owner);
154
- const source = validateModelTasksetPackage(input.source);
166
+ const source = input.source;
167
+ const edited = input.edits ?? source;
155
168
  const previous = source.taskset.metadata.modelTasksetDerivation === void 0 ? null : ModelTasksetDerivationSchema.parse(source.taskset.metadata.modelTasksetDerivation);
156
169
  if (previous && source.taskset.id !== identity(previous.owner, previous.root)) throw new Error("Derived Taskset identity differs from its ownership lineage.");
157
170
  const owned = previous && same(previous.owner, owner);
@@ -162,13 +175,13 @@ function deriveModelTaskset(input) {
162
175
  const rewards = input.rewards.map((reward) => RewardReleaseSchema.parse(reward));
163
176
  const graders = compileBoundGraders(rewardBinding, rewards);
164
177
  if (rewardBinding.recipeRef) throw new Error("Resolve the Reward recipe into one standalone binding before deriving a Taskset.");
165
- const policy = { ...source.taskset.policy, hiddenGraderRefs: graders.filter((grader) => grader.privileged).map((grader) => grader.id) };
166
- const previousResources = source.executionResources ?? source.execution;
178
+ const policy = { ...edited.taskset.policy, hiddenGraderRefs: graders.filter((grader) => grader.privileged).map((grader) => grader.id) };
179
+ const previousResources = edited.executionResources ?? edited.execution;
167
180
  const environment = previousResources?.environment ?? createEnvironmentRelease({
168
181
  schemaVersion: "openpond.environmentRelease.v1",
169
182
  id: `${id}-environment`,
170
183
  revision: 1,
171
- contract: source.taskset.environment,
184
+ contract: edited.taskset.environment,
172
185
  actionSchemaRef: null,
173
186
  observationSchemaRef: null,
174
187
  stateSchemaRef: null,
@@ -181,17 +194,17 @@ function deriveModelTaskset(input) {
181
194
  id: `${id}-verifiers`,
182
195
  revision,
183
196
  graders,
184
- isolation: previousResources?.verifierSet.isolation ?? { processBoundary: "isolated_process", networkPolicy: "none", defaultTimeoutMs: Math.min(source.taskset.environment.defaultTimeoutMs, 3e5) },
197
+ isolation: previousResources?.verifierSet.isolation ?? { processBoundary: "isolated_process", networkPolicy: "none", defaultTimeoutMs: Math.min(edited.taskset.environment.defaultTimeoutMs, 3e5) },
185
198
  calibrationReceiptRefs: [],
186
199
  metadata: previousResources ? { sourceVerifierSet: learningRef2(previousResources.verifierSet) } : {}
187
200
  });
188
201
  const executionResources = { environment, verifierSet };
189
- const execution = source.execution ? { ...source.execution, verifierSet } : void 0;
190
- const { contentHash: _taskHash, ...taskContent } = source.taskset;
191
- const { contentHash: _definitionHash, ...definitionContent } = source.taskDefinition;
202
+ const execution = edited.execution ? { ...edited.execution, verifierSet } : void 0;
203
+ const { contentHash: _taskHash, ...taskContent } = edited.taskset;
204
+ const { contentHash: _definitionHash, ...definitionContent } = edited.taskDefinition;
192
205
  const taskExecution = { ...definitionContent.execution, policy, environmentRelease: { id: environment.id, contentHash: environment.contentHash }, verifierSetRelease: { id: verifierSet.id, contentHash: verifierSet.contentHash } };
193
206
  const taskDefinition = TaskDefinitionSchema.parse(sealLearningContent3({ ...definitionContent, id: `${id}-definition`, revision, rewardBinding: learningRef2(rewardBinding), execution: taskExecution }));
194
- const authoring = source.taskset.metadata.starterAuthoring;
207
+ const authoring = source.taskset.metadata.starterAuthoring ?? source.taskset.metadata.ordinaryAuthoring;
195
208
  const graderFixtures = authoring && typeof authoring === "object" && !Array.isArray(authoring) && "graderFixtures" in authoring ? authoring.graderFixtures : void 0;
196
209
  const taskset = TasksetReleaseSchema.parse(sealLearningContent3({
197
210
  ...taskContent,
@@ -203,10 +216,11 @@ function deriveModelTaskset(input) {
203
216
  starter: { taskDefinition: learningRef2(taskDefinition), rewardBinding: learningRef2(rewardBinding) },
204
217
  rewardExecution: { binding: rewardBinding, rewards },
205
218
  ...graderFixtures === void 0 ? {} : { starterAuthoring: { graderFixtures } },
219
+ ...edited.taskset.metadata.environmentResources === void 0 ? {} : { environmentResources: edited.taskset.metadata.environmentResources },
206
220
  modelTasksetDerivation: { schemaVersion: "openpond.modelTasksetDerivation.v1", owner, root, parent: learningRef2(source.taskset) }
207
221
  }
208
222
  }));
209
- return validateModelTasksetPackage({ taskset, taskDefinition, rewardBinding, rewards, assets: input.assets, executionResources, ...execution ? { execution } : {} });
223
+ return validateModelTasksetPackage({ taskset, taskDefinition, rewardBinding, rewards, assets: input.assets, executionResources, ...execution ? { execution } : {}, ...source.instructionMode ? { instructionMode: source.instructionMode } : {} });
210
224
  }
211
225
  function validateModelTasksetPackage(value) {
212
226
  const result = ModelTasksetPackageSchema.parse(value);
@@ -238,7 +252,7 @@ function validateModelTasksetPackage(value) {
238
252
  }
239
253
  for (const task of taskset.tasks) {
240
254
  if (taskDefinition.requiredOutputs && !same(task.requiredOutputs, taskDefinition.requiredOutputs)) throw new Error(`Taskset outputs differ from its reviewed definition: ${task.id}.`);
241
- if (task.policyVisibleContext.instructions !== taskDefinition.instructions || !validateTaskValue(taskDefinition.inputSchema, task.input).valid || task.expectedOutput !== null && !validateTaskValue(taskDefinition.outputSchema, task.expectedOutput).valid) throw new Error(`Taskset task differs from its declared format: ${task.id}.`);
255
+ if (result.instructionMode !== "per_task" && task.policyVisibleContext.instructions !== taskDefinition.instructions || !validateTaskValue(taskDefinition.inputSchema, task.input).valid || task.expectedOutput !== null && !validateTaskValue(taskDefinition.outputSchema, task.expectedOutput).valid) throw new Error(`Taskset task differs from its declared format: ${task.id}.`);
242
256
  if (task.privilegedContextRef && !assets.some((asset) => asset.id === task.privilegedContextRef && asset.asset.visibility === "host_private")) throw new Error(`Taskset private context is missing: ${task.id}.`);
243
257
  }
244
258
  for (const reward of rewards) {
@@ -253,6 +267,275 @@ function validateModelTasksetPackage(value) {
253
267
  return result;
254
268
  }
255
269
 
270
+ // src/taskset-package-learning.ts
271
+ import { z as z4 } from "zod";
272
+ import {
273
+ TaskBatchSchema,
274
+ TaskEvidenceSchema,
275
+ TaskAdmissionDecisionSchema,
276
+ LearningSourceSchema,
277
+ LearningTextAssetSchema as LearningTextAssetSchema2,
278
+ assertLearningContentHash as assertLearningContentHash2,
279
+ compileTaskBatch,
280
+ learningRef as learningRef3,
281
+ sameLearningRef as sameLearningRef2,
282
+ taskBatchPackageMetadata,
283
+ verifyLearningTextAsset as verifyLearningTextAsset4
284
+ } from "@openpond/evals/learning";
285
+ var TasksetPackageLearningResourcesSchema = z4.object({
286
+ batch: TaskBatchSchema,
287
+ evidence: z4.array(TaskEvidenceSchema).min(1).max(1e4),
288
+ decisions: z4.array(TaskAdmissionDecisionSchema).min(1).max(1e4),
289
+ sources: z4.array(LearningSourceSchema).min(1).max(1e4),
290
+ assets: z4.array(LearningTextAssetSchema2).max(1e3)
291
+ }).strict();
292
+ function learningPackageContextFiles(resources) {
293
+ return resources.evidence.filter((evidence) => evidence.submission.evaluatorContext !== null).map((evidence) => {
294
+ const text = canonicalJson(evidence.submission.evaluatorContext);
295
+ const bytes = new TextEncoder().encode(text);
296
+ return {
297
+ asset: {
298
+ id: `task-evidence:${evidence.contentHash}`,
299
+ path: `learning/context/${evidence.contentHash}.json`,
300
+ contentHash: sha256(bytes),
301
+ sizeBytes: bytes.byteLength,
302
+ mediaType: "application/json",
303
+ visibility: "host_private"
304
+ },
305
+ base64: btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(""))
306
+ };
307
+ });
308
+ }
309
+ function validateTasksetLearningResources(taskset, input) {
310
+ const resources = TasksetPackageLearningResourcesSchema.parse(input);
311
+ const metadata = taskBatchPackageMetadata(taskset);
312
+ if (!sameLearningRef2(learningRef3(resources.batch), metadata.batch)) throw new Error("Taskset learning batch differs from its admission metadata.");
313
+ for (const collection of [resources.evidence, resources.decisions, resources.sources, resources.assets]) {
314
+ const identities = /* @__PURE__ */ new Set();
315
+ for (const resource of collection) {
316
+ assertLearningContentHash2(resource);
317
+ const key = `${resource.id}:${resource.revision}`;
318
+ if (identities.has(key)) throw new Error("Taskset learning resource identities must be unique.");
319
+ identities.add(key);
320
+ }
321
+ }
322
+ if (resources.evidence.length !== resources.batch.examples.length || resources.decisions.length !== resources.batch.examples.length) throw new Error("Taskset learning snapshots must match the admitted batch inventory.");
323
+ for (const evidence of resources.evidence) {
324
+ const source = resources.sources.find((source2) => sameLearningRef2(learningRef3(source2), evidence.source));
325
+ if (!source || !sameLearningRef2(source.taskDefinition, learningRef3(metadata.definition))) throw new Error("Taskset evidence source differs from its task definition.");
326
+ }
327
+ if (resources.sources.some((source) => !resources.evidence.some((evidence) => sameLearningRef2(evidence.source, learningRef3(source))))) throw new Error("Taskset package includes an unrelated learning source.");
328
+ const rewardAssets = metadata.rewards.flatMap((reward) => [
329
+ ...reward.assets,
330
+ ...reward.implementation.kind === "custom_verifier" ? [reward.implementation.verifierRef] : reward.implementation.kind === "model_judge" || reward.implementation.kind === "human" ? [reward.implementation.rubricRef] : [],
331
+ ..."inputContract" in reward.implementation ? [reward.implementation.inputContract] : []
332
+ ]);
333
+ for (const ref of rewardAssets) {
334
+ const asset = resources.assets.find((asset2) => asset2.id === ref.id);
335
+ if (!asset) throw new Error("Taskset learning Reward asset is missing.");
336
+ verifyLearningTextAsset4(asset, ref);
337
+ }
338
+ if (resources.assets.some((asset) => !rewardAssets.some((ref) => ref.id === asset.id))) throw new Error("Taskset package includes an unrelated learning asset.");
339
+ const compiled = compileTaskBatch({
340
+ batch: resources.batch,
341
+ definition: metadata.definition,
342
+ binding: metadata.binding,
343
+ rewards: metadata.rewards,
344
+ evidence: resources.evidence,
345
+ decisions: resources.decisions
346
+ });
347
+ const compiledMetadata = taskBatchPackageMetadata(compiled);
348
+ if (contentHash(compiledMetadata) !== contentHash(metadata)) throw new Error("Taskset admission metadata differs from its reviewed snapshots.");
349
+ const execution = (release) => ({ policy: release.policy, environment: release.environment, tools: release.tools });
350
+ if (contentHash(execution(compiled)) !== contentHash(execution(taskset))) throw new Error("Taskset execution differs from its reviewed task definition.");
351
+ const taskContent = (task) => ({
352
+ id: task.id,
353
+ clusterKey: task.clusterKey,
354
+ split: task.split,
355
+ input: task.input,
356
+ expectedOutput: task.expectedOutput,
357
+ policyVisibleContext: task.policyVisibleContext,
358
+ privilegedContextRef: task.privilegedContextRef,
359
+ artifactRefs: task.artifactRefs,
360
+ requiredOutputs: task.requiredOutputs ?? [],
361
+ tags: task.tags
362
+ });
363
+ if (contentHash(compiled.tasks.map(taskContent)) !== contentHash(taskset.tasks.map(taskContent))) throw new Error("Taskset rows differ from their reviewed evidence.");
364
+ return resources;
365
+ }
366
+
367
+ // src/taskset-package-files.ts
368
+ import { z as z5 } from "zod";
369
+ var MAX_TASKSET_PACKAGE_BYTES = 64 * 1024 * 1024;
370
+ var TasksetPackageFileSchema = z5.object({
371
+ asset: ImmutableAssetRefSchema,
372
+ base64: z5.string().max(Math.ceil(MAX_TASKSET_PACKAGE_BYTES / 3) * 4)
373
+ }).strict();
374
+ function decodeTasksetPackageFile(value) {
375
+ const file = TasksetPackageFileSchema.parse(value);
376
+ const raw = atob(file.base64);
377
+ if (btoa(raw) !== file.base64) throw new Error(`Taskset asset ${file.asset.id} has noncanonical base64.`);
378
+ const bytes = Uint8Array.from(raw, (character) => character.charCodeAt(0));
379
+ if (bytes.byteLength !== file.asset.sizeBytes || sha256(bytes) !== file.asset.contentHash) throw new Error(`Taskset asset ${file.asset.id} differs from its immutable bytes.`);
380
+ return bytes;
381
+ }
382
+
383
+ // src/taskset-package-execution.ts
384
+ import { LearningTextAssetSchema as LearningTextAssetSchema3, sealLearningContent as sealLearningContent4 } from "@openpond/evals/learning";
385
+ function resolveTasksetPackageExecution(input) {
386
+ if (input.taskset.environment.entrypoint !== "openpond.javascript-environment.v1") return null;
387
+ const byId = new Map(input.files.map((file) => [file.asset.id, file]));
388
+ const read = (id) => {
389
+ const file = byId.get(id);
390
+ if (!file) throw new Error(`Taskset environment asset is missing: ${id}.`);
391
+ if (file.asset.sizeBytes > 524288) throw new Error("Taskset environment source exceeds the authored asset limit.");
392
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(decodeTasksetPackageFile(file));
393
+ return LearningTextAssetSchema3.parse(sealLearningContent4({ schemaVersion: "openpond.learningTextAsset.v1", id, revision: 1, asset: file.asset, text }));
394
+ };
395
+ let execution;
396
+ if (input.modelResources) {
397
+ if (!input.modelResources.execution) throw new Error("Bound Taskset JavaScript execution resources are missing.");
398
+ execution = ModelStarterExecutionSchema.parse(input.modelResources.execution);
399
+ } else {
400
+ const declaration = read(modelStarterExecutionAssetId(input.taskset));
401
+ if (declaration.asset.visibility !== "host_private" || declaration.asset.mediaType !== "application/json" || declaration.asset.path !== "environment/execution.json") throw new Error("Taskset execution declaration must be private JSON at environment/execution.json.");
402
+ execution = ModelStarterExecutionSchema.parse(JSON.parse(declaration.text));
403
+ }
404
+ const ids = /* @__PURE__ */ new Set([
405
+ execution.javascript.module.id,
406
+ ...[execution.environment.actionSchemaRef, execution.environment.observationSchemaRef, execution.environment.stateSchemaRef].flatMap((ref) => ref ? [ref.id] : []),
407
+ ...input.taskset.tasks.flatMap((task) => task.privilegedContextRef ? [task.privilegedContextRef] : [])
408
+ ]);
409
+ const assets = [...ids].map(read);
410
+ validateModelStarterExecution(execution, input.taskset, assets);
411
+ return { execution, assets };
412
+ }
413
+ function createTasksetPackageExecutionFile(execution) {
414
+ const asset = createModelStarterExecutionAsset(execution);
415
+ const bytes = new TextEncoder().encode(asset.text);
416
+ let raw = "";
417
+ for (const byte of bytes) raw += String.fromCharCode(byte);
418
+ return { asset: asset.asset, base64: btoa(raw) };
419
+ }
420
+
421
+ // src/taskset-package-contracts.ts
422
+ import { z as z6 } from "zod";
423
+ import { EnvironmentReleaseSchema as EnvironmentReleaseSchema3, VerifierSetReleaseSchema as VerifierSetReleaseSchema3, verifyEnvironmentRelease as verifyEnvironmentRelease3, verifyVerifierSetRelease as verifyVerifierSetRelease3 } from "@openpond/evals";
424
+ import { assertTasksetRelease as assertTasksetRelease2, TasksetReleaseSchema as TasksetReleaseSchema2 } from "@openpond/evals/tasksets";
425
+ import { assertBoundedTaskJson as assertBoundedTaskJson2 } from "@openpond/evals/task-schema";
426
+ import { taskBatchPackageMetadata as taskBatchPackageMetadata2 } from "@openpond/evals/learning";
427
+
428
+ // src/model-taskset-authoring-lineage.ts
429
+ import { sameLearningRef as sameLearningRef3 } from "@openpond/evals/learning";
430
+ function modelAuthoredTasksetId(lineage) {
431
+ return `model-authored-taskset-${contentHash({ owner: lineage.owner, root: lineage.root })}`;
432
+ }
433
+ function assertModelTasksetAuthoring(taskset) {
434
+ if (taskset.metadata.modelTasksetAuthoring === void 0) return null;
435
+ const lineage = ModelTasksetAuthoringSchema.parse(taskset.metadata.modelTasksetAuthoring);
436
+ if (taskset.id !== modelAuthoredTasksetId(lineage) || (taskset.revision === 1 ? !sameLearningRef3(lineage.parent, lineage.root) : lineage.parent.id !== taskset.id || lineage.parent.revision !== taskset.revision - 1)) {
437
+ throw new Error("Authored Taskset revision differs from its ownership lineage.");
438
+ }
439
+ return lineage;
440
+ }
441
+
442
+ // src/taskset-package-contracts.ts
443
+ var BoundModelResourcesSchema = ModelTasksetPackageSchema.omit({ taskset: true, executionResources: true });
444
+ var TasksetPackageContentSchema = z6.object({
445
+ schemaVersion: z6.literal("openpond.tasksetPackage.v1"),
446
+ taskset: TasksetReleaseSchema2,
447
+ environment: EnvironmentReleaseSchema3,
448
+ verifierSet: VerifierSetReleaseSchema3,
449
+ files: z6.array(TasksetPackageFileSchema).max(1e4),
450
+ modelResources: BoundModelResourcesSchema.optional(),
451
+ learningResources: TasksetPackageLearningResourcesSchema.optional()
452
+ }).strict();
453
+ var TasksetPackageSchema = TasksetPackageContentSchema.extend({ contentHash: z6.string().regex(/^[a-f0-9]{64}$/) }).strict();
454
+ function tasksetPackageRewardBinding(value) {
455
+ return value.learningResources ? taskBatchPackageMetadata2(value.taskset).binding : value.modelResources?.rewardBinding ?? null;
456
+ }
457
+ function resolveTasksetPackageInstructions(value) {
458
+ if (value.learningResources) return taskBatchPackageMetadata2(value.taskset).definition.instructions;
459
+ if (value.modelResources) return value.modelResources.taskDefinition.instructions;
460
+ const authoring = z6.object({ instructions: z6.string().max(2e4).optional() }).passthrough().parse(value.taskset.metadata.ordinaryAuthoring ?? {});
461
+ return authoring.instructions ?? "";
462
+ }
463
+ function validateTasksetPackage(value) {
464
+ assertBoundedTaskJson2(value, MAX_TASKSET_PACKAGE_BYTES);
465
+ const result = TasksetPackageSchema.parse(value);
466
+ const { contentHash: hash, ...content } = result;
467
+ if (contentHash(content) !== hash) throw new Error("Taskset package content hash differs from its bytes.");
468
+ const { taskset, environment, verifierSet } = result;
469
+ assertTasksetRelease2(taskset);
470
+ const authoring = assertModelTasksetAuthoring(taskset);
471
+ if (authoring && (result.modelResources || result.learningResources)) throw new Error("Taskset package cannot declare competing authoring graphs.");
472
+ if (!verifyEnvironmentRelease3(environment) || !verifyVerifierSetRelease3(verifierSet) || !same2(taskset.environmentRelease, { id: environment.id, contentHash: environment.contentHash }) || !same2(taskset.verifierSetRelease, { id: verifierSet.id, contentHash: verifierSet.contentHash }) || !same2(taskset.environment, environment.contract) || !same2(taskset.graders, verifierSet.graders)) {
473
+ throw new Error("Taskset package execution releases do not match its Taskset.");
474
+ }
475
+ const files = /* @__PURE__ */ new Map();
476
+ for (const file of result.files) {
477
+ if (files.has(file.asset.id)) throw new Error(`Duplicate Taskset asset identity: ${file.asset.id}.`);
478
+ decodeTasksetPackageFile(file);
479
+ files.set(file.asset.id, file);
480
+ }
481
+ function requireAsset(ref) {
482
+ const file = files.get(ref.id);
483
+ if (!file || !same2(file.asset, ref)) throw new Error(`Taskset package asset is missing or mismatched: ${ref.id}.`);
484
+ }
485
+ for (const task of taskset.tasks) {
486
+ for (const asset of task.artifactRefs) requireAsset(asset);
487
+ for (const output of task.requiredOutputs ?? []) if (output.schemaRef) requireAsset(output.schemaRef);
488
+ if (task.privilegedContextRef && files.get(task.privilegedContextRef)?.asset.visibility !== "host_private") {
489
+ throw new Error(`Taskset package private context is missing: ${task.id}.`);
490
+ }
491
+ }
492
+ for (const ref of [environment.actionSchemaRef, environment.observationSchemaRef, environment.stateSchemaRef]) if (ref) requireAsset(ref);
493
+ for (const grader of taskset.graders) {
494
+ const ref = "verifierRef" in grader ? grader.verifierRef : "rubricRef" in grader ? grader.rubricRef : null;
495
+ if (ref) {
496
+ requireAsset(ref);
497
+ if (ref.visibility === "policy") throw new Error(`Taskset grader asset must be private: ${ref.id}.`);
498
+ }
499
+ }
500
+ if (taskset.metrics?.customAggregator) {
501
+ const aggregator = taskset.metrics.customAggregator;
502
+ const modules = result.files.filter((file) => file.asset.path === aggregator.module);
503
+ if (modules.length !== 1 || modules[0].asset.contentHash !== aggregator.contentHash || modules[0].asset.sizeBytes > 524288 || modules[0].asset.visibility === "policy") {
504
+ throw new Error("Taskset metric module is missing or mismatched, public, or exceeds the source limit.");
505
+ }
506
+ }
507
+ for (const declarations of [taskset.metadata.environmentResources, environment.metadata.resources]) {
508
+ if (declarations === void 0) continue;
509
+ for (const resource of z6.array(z6.object({ path: z6.string().min(1) }).passthrough()).parse(declarations)) {
510
+ if (!result.files.some((file) => file.asset.path === resource.path)) throw new Error(`Taskset environment resource is missing: ${resource.path}.`);
511
+ }
512
+ }
513
+ if (result.learningResources) {
514
+ if (result.modelResources) throw new Error("Taskset package cannot declare competing authoring graphs.");
515
+ const learning = validateTasksetLearningResources(taskset, result.learningResources);
516
+ for (const expected of learningPackageContextFiles(learning)) {
517
+ if (!same2(files.get(expected.asset.id), expected)) throw new Error("Taskset private context differs from its reviewed evidence.");
518
+ }
519
+ for (const asset of learning.assets) requireAsset(asset.asset);
520
+ } else if (result.modelResources) {
521
+ const model = validateModelTasksetPackage({ ...result.modelResources, taskset, executionResources: { environment, verifierSet } });
522
+ for (const asset of model.assets) requireAsset(asset.asset);
523
+ } else if (["starter", "rewardBinding", "rewardExecution", "modelTasksetDerivation", "learning"].some((key) => taskset.metadata[key] !== void 0)) {
524
+ throw new Error("Bound Taskset publication requires its complete model resources.");
525
+ }
526
+ resolveTasksetPackageExecution(result);
527
+ resolveTasksetPackageInstructions(result);
528
+ return result;
529
+ }
530
+ function createTasksetPackage(value) {
531
+ assertBoundedTaskJson2(value, MAX_TASKSET_PACKAGE_BYTES);
532
+ const content = TasksetPackageContentSchema.parse(value);
533
+ return validateTasksetPackage({ ...content, contentHash: contentHash(content) });
534
+ }
535
+ function same2(left, right) {
536
+ return contentHash({ value: left }) === contentHash({ value: right });
537
+ }
538
+
256
539
  export {
257
540
  ModelStarterEnvironmentAttemptSchema,
258
541
  verifyModelStarterEnvironmentAttempt,
@@ -269,6 +552,23 @@ export {
269
552
  ModelTasksetDerivationSchema,
270
553
  ModelTasksetPackageSchema,
271
554
  deriveModelTaskset,
272
- validateModelTasksetPackage
555
+ compileModelTasksetReward,
556
+ validateModelTasksetPackage,
557
+ TasksetPackageLearningResourcesSchema,
558
+ learningPackageContextFiles,
559
+ validateTasksetLearningResources,
560
+ modelAuthoredTasksetId,
561
+ assertModelTasksetAuthoring,
562
+ MAX_TASKSET_PACKAGE_BYTES,
563
+ TasksetPackageFileSchema,
564
+ decodeTasksetPackageFile,
565
+ resolveTasksetPackageExecution,
566
+ createTasksetPackageExecutionFile,
567
+ TasksetPackageContentSchema,
568
+ TasksetPackageSchema,
569
+ tasksetPackageRewardBinding,
570
+ resolveTasksetPackageInstructions,
571
+ validateTasksetPackage,
572
+ createTasksetPackage
273
573
  };
274
- //# sourceMappingURL=chunk-GFVMIDP5.js.map
574
+ //# sourceMappingURL=chunk-B3CH4V35.js.map