openpond-sdk 0.12.17 → 0.12.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/TRAINING_WORKFLOWS.md +15 -0
  2. package/dist/{chunk-VPK3SM45.js → chunk-BJMENXR4.js} +2 -1
  3. package/dist/{chunk-VPK3SM45.js.map → chunk-BJMENXR4.js.map} +1 -1
  4. package/dist/learning.js +2 -2
  5. package/dist/learning.js.map +1 -1
  6. package/dist/post-training.js +1 -1
  7. package/dist/training-bundle.js +1 -1
  8. package/dist/training.js +1102 -971
  9. package/dist/training.js.map +1 -1
  10. package/dist/types/packages/sdk/src/dataset-training-review.d.ts.map +1 -1
  11. package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts +1057 -57
  12. package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts.map +1 -1
  13. package/dist/types/packages/sdk/src/experiment-evaluation-schedules.d.ts +216 -216
  14. package/dist/types/packages/sdk/src/experiment-improvement-client.d.ts +1889 -1889
  15. package/dist/types/packages/sdk/src/managed-training-preparation.d.ts +25 -25
  16. package/dist/types/packages/sdk/src/model-taskset-runs.d.ts +216 -216
  17. package/dist/types/packages/sdk/src/post-training.d.ts +1 -0
  18. package/dist/types/packages/sdk/src/post-training.d.ts.map +1 -1
  19. package/dist/types/packages/sdk/src/steering-model-serving.d.ts +1349 -1349
  20. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +120 -120
  21. package/dist/types/packages/sdk/src/training-experiment-learning-intent.d.ts +26 -0
  22. package/dist/types/packages/sdk/src/training-experiment-learning-intent.d.ts.map +1 -0
  23. package/dist/types/packages/sdk/src/training-experiment-learning.d.ts +699 -0
  24. package/dist/types/packages/sdk/src/training-experiment-learning.d.ts.map +1 -0
  25. package/dist/types/packages/sdk/src/training-experiment-setup.d.ts +573 -0
  26. package/dist/types/packages/sdk/src/training-experiment-setup.d.ts.map +1 -1
  27. package/dist/types/packages/sdk/src/training-harness-sources.d.ts +2 -2
  28. package/dist/types/packages/sdk/src/training-learning-batch.d.ts +40 -40
  29. package/dist/types/packages/sdk/src/training-qualification-preparation.d.ts +25 -25
  30. package/dist/types/packages/sdk/src/training.d.ts +1178 -1064
  31. package/dist/types/packages/sdk/src/training.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -623,3 +623,18 @@ This read returns the owned execution's exact request, lifecycle phase and any r
623
623
  On a compatible host, `compileModificationExecution(input)` compiles a bounded raw form with the exact registered tokenizer. `prepareModificationExecution(input)` retains the compiled request, Project, name and maximum spend without starting compute. After explicit review, `startModificationExecution(input)` uses the returned execution ID, revision, plan hash, approved cap and a stable operation ID. `cancelModificationExecution(input)` retains that exact execution identity while cleanup proceeds.
624
624
 
625
625
  The CLI equivalents are `training hosted-compile-modification`, `hosted-prepare-modification`, `hosted-start-modification --yes` and `hosted-cancel-modification`, each taking `<input.json> --team-id <id>`. Native Python provides corresponding snake_case methods in both clients. Use the exported input schemas or installed help; preserve the original command and operation ID after an uncertain reply. Start is the funded execution boundary. An unavailable capability never grants permission to start an unsupported model.
626
+
627
+ ## Continual-learning grader selection
628
+
629
+ An experiment draft's `trainingForm.learningIntent.graders` optionally stores
630
+ exact learning revision references for recurring tasks. Omitting the field uses
631
+ the reviewed batch's whole grader pool. An explicit subset must retain required
632
+ gates and the training/evaluation roles needed by the hosted loop. Hosts validate
633
+ these references against the exact reviewed batch before publishing the policy.
634
+
635
+ The learning save hashes this selection and retains it in the immutable policy;
636
+ it does not rewrite the manual experiment's batch or grader binding. The retained
637
+ evaluation remains an independent candidate check. A nightly schedule uses the
638
+ authored time and timezone, waits for approved unused examples, and respects the
639
+ saved task threshold and spend limits. It does not itself enable conversation
640
+ collection, automatic data approval, or automatic serving.
@@ -258,6 +258,7 @@ var HostedTrainingSetupActionSchema = z.enum([
258
258
  "archive-draft",
259
259
  "prepare",
260
260
  "prepare-draft",
261
+ "save-experiment-learning",
261
262
  "review-dataset",
262
263
  "start",
263
264
  "cancel",
@@ -307,4 +308,4 @@ export {
307
308
  HostedTrainingPolicyControlSchema,
308
309
  TrainingHandoffOriginSchema2 as TrainingHandoffOriginSchema
309
310
  };
310
- //# sourceMappingURL=chunk-VPK3SM45.js.map
311
+ //# sourceMappingURL=chunk-BJMENXR4.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/post-training.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport {\n LearningSourceSchema,\n TaskBatchSchema,\n TaskDefinitionSchema,\n LearningPolicySchema,\n LearningPolicyInspectionResultSchema,\n LearningIterationSchema,\n} from \"@openpond/evals/learning\";\nimport { HostedModelProjectSummarySchema } from \"./model-projects.js\";\nimport { AcceptancePlanSchema } from \"@openpond/evals/learning\";\nimport { TrainingHandoffOriginSchema } from \"@openpond/evals/learning\";\nexport { TrainingHandoffOriginSchema, type TrainingHandoffOrigin } from \"@openpond/evals/learning\";\nimport { RunExperimentSchema } from \"./experiment-run-contracts.js\";\nimport { canonicalSha256, OpenPondProtocolError } from \"./protocol.js\";\n\nconst Id = z.string().trim().min(1).max(200);\nconst Hash = z.string().regex(/^[a-f0-9]{64}$/);\nconst Ref = z.object({ id: Id, contentHash: Hash }).strict();\nexport const TrainingHandoffContextSchema = z\n .object({\n available: z.boolean(),\n reason: z.string().max(1000).nullable(),\n origin: TrainingHandoffOriginSchema.nullable(),\n })\n .strict();\nexport type TrainingHandoffContext = z.infer<typeof TrainingHandoffContextSchema>;\nexport const PostTrainingAttachmentSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.postTrainingAttachment.v1\"),\n binding: z\n .object({\n kind: z.enum([\"preparation\", \"policy\"]),\n id: Id,\n revision: z.number().int().positive(),\n contentHash: Hash,\n })\n .strict(),\n projectId: Id.nullable(),\n automatic: z.boolean(),\n maximumSpendUsd: z.number().finite().positive().max(10_000),\n experiments: z\n .array(z.object({ id: Id, configuration: RunExperimentSchema }).strict())\n .min(1)\n .max(20),\n acceptancePlan: AcceptancePlanSchema.nullable(),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (new Set(value.experiments.map((item) => item.id)).size !== value.experiments.length)\n ctx.addIssue({ code: \"custom\", message: \"Attach each evaluation once.\" });\n if (\n value.experiments.reduce((sum, item) => sum + item.configuration.maximumCostUsd, 0) >\n value.maximumSpendUsd + 1e-9\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Attached evaluation budgets exceed the total approved budget.\",\n });\n if (\n value.experiments.some(\n (item) => (item.configuration.request.project?.id ?? null) !== value.projectId,\n )\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Attached experiments must use the training Project.\",\n });\n if (value.acceptancePlan) {\n const checked = new Set(value.acceptancePlan.checks.map((c) => c.id));\n if (value.acceptancePlan.checks.some((c) => !value.experiments.some((m) => m.id === c.id)))\n ctx.addIssue({\n code: \"custom\",\n message: \"Select the frozen Experiment for each acceptance check.\",\n });\n const committed =\n value.acceptancePlan.maximumSpendUsd +\n value.experiments\n .filter((m) => !checked.has(m.id))\n .reduce((sum, m) => sum + m.configuration.maximumCostUsd, 0);\n if (committed > value.maximumSpendUsd + 1e-9)\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Paired acceptance and diagnostic ceilings exceed the approved evaluation budget.\",\n });\n }\n });\nexport type PostTrainingAttachment = z.infer<typeof PostTrainingAttachmentSchema>;\n/** Target-independent recipe pins keep the paired baseline/candidate check on\n * the same released data, case order, settings and graders. */\nexport function postTrainingRecipe(\n configuration: PostTrainingAttachment[\"experiments\"][number][\"configuration\"],\n) {\n const {\n modelId: _model,\n candidate: _candidate,\n ...settings\n } = configuration.request.policy.kind === \"fixture\"\n ? { modelId: null, candidate: null, ...configuration.request.policy }\n : configuration.request.policy;\n void _model;\n void _candidate;\n if (\"modelConfigurationHash\" in settings)\n delete (settings as { modelConfigurationHash?: string }).modelConfigurationHash;\n return {\n dataset: {\n id: configuration.request.taskset.id,\n contentHash: configuration.request.taskset.contentHash,\n },\n populationHash: contentHash(\n configuration.request.population.map((m) => ({\n caseId: m.taskId,\n seed: m.seed,\n fixtureId: m.fixtureId,\n })),\n ),\n executionHash: contentHash({ settings, graders: configuration.graders ?? null }),\n };\n}\nexport const PostTrainingQualificationSchema = z\n .object({\n baseline: Ref,\n checks: z\n .array(\n z\n .object({\n id: Id,\n sourceRunId: Id,\n sourceManifestHash: Hash,\n targetConfigurationHash: Hash,\n executionHash: Hash,\n populationHash: Hash,\n evaluator: Ref,\n feedbackKey: Id,\n output: z.enum([\"boolean\", \"score\"]),\n unit: z.string().min(1).max(80),\n })\n .strict(),\n )\n .min(1)\n .max(100),\n })\n .strict();\nexport const PostTrainingStateSchema = z.enum([\n \"waiting_for_training\",\n \"ready\",\n \"preparing\",\n \"queued\",\n \"running\",\n \"cleaning\",\n \"completed\",\n \"failed\",\n \"blocked\",\n \"cancelled\",\n \"budget_exhausted\",\n]);\nexport const PostTrainingSummarySchema = z\n .object({\n schemaVersion: z.literal(\"openpond.postTrainingSummary.v1\"),\n id: Id,\n teamId: Id,\n jobId: Id,\n revision: z.number().int().positive(),\n planHash: Hash,\n automatic: z.boolean(),\n candidate: Ref.nullable(),\n state: PostTrainingStateSchema,\n total: z.number().int().positive(),\n completed: z.number().int().nonnegative(),\n failed: z.number().int().nonnegative(),\n requiredOutcome: z.enum([\"none\", \"pending\", \"passed\", \"failed\", \"blocked\"]),\n reason: z.string().max(500).nullable(),\n groupId: Id.nullable(),\n experimentIds: z.array(Id).max(20),\n updatedAt: z.iso.datetime(),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (value.completed + value.failed > value.total)\n ctx.addIssue({ code: \"custom\", message: \"Evaluation totals are inconsistent.\" });\n if (\n [\"preparing\", \"queued\", \"running\", \"cleaning\", \"completed\"].includes(value.state) &&\n !value.candidate\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Evaluation execution requires the exact trained candidate.\",\n });\n });\nexport type PostTrainingSummary = z.infer<typeof PostTrainingSummarySchema>;\nexport const PostTrainingControlSchema = z\n .object({ operationId: Id, expectedRevision: z.number().int().positive(), planHash: Hash })\n .strict();\nexport const AttachPostTrainingSchema = z\n .object({ operationId: Id, attachment: PostTrainingAttachmentSchema })\n .strict();\nexport const PostTrainingPlanSchema = z\n .object({\n id: Id,\n teamId: Id,\n ownerUserId: Id,\n attachment: PostTrainingAttachmentSchema,\n qualification: PostTrainingQualificationSchema.nullable(),\n contentHash: Hash,\n createdAt: z.iso.datetime(),\n })\n .strict();\nexport type PostTrainingPlan = z.infer<typeof PostTrainingPlanSchema>;\nexport function verifyPostTrainingPlan(raw: unknown): PostTrainingPlan {\n const plan = PostTrainingPlanSchema.parse(raw);\n if (\n plan.contentHash !==\n contentHash({ attachment: plan.attachment, qualification: plan.qualification })\n )\n throw new Error(\"The retained evaluation attachment or qualification changed.\");\n return plan;\n}\nexport function postTrainingActive(summary: PostTrainingSummary | null | undefined) {\n return Boolean(summary && [\"preparing\", \"queued\", \"running\", \"cleaning\"].includes(summary.state));\n}\n\n/** Read/setup are configuration-only. Manual start authorizes exactly the\n * retained candidate, plan and revision. A retry never launches training. */\nexport function createPostTrainingClient(input: {\n request: (path: string, init?: RequestInit) => Promise<unknown>;\n}) {\n const { request } = input;\n // These public evaluation routes consume ordinary JSON, independently of\n // the versioned Training V2 job routes used by the parent factory.\n const headers = { accept: \"application/json\", \"content-type\": \"application/json\" };\n const path = (jobId: string) =>\n `/v1/training/jobs/${encodeURIComponent(Id.parse(jobId))}/post-training`;\n async function read(raw: unknown, teamId: string, jobId: string) {\n if (raw === null) return null;\n const value = PostTrainingSummarySchema.parse(raw);\n if (value.teamId !== teamId || value.jobId !== jobId)\n throw new OpenPondProtocolError(\n \"post_training_scope_mismatch\",\n \"The evaluation summary belongs to another run or workspace.\",\n );\n return value;\n }\n return {\n async attach(teamId: string, raw: z.input<typeof AttachPostTrainingSchema>) {\n const body = AttachPostTrainingSchema.parse(raw);\n const value = verifyPostTrainingPlan(\n await request(\"/v1/training/post-training-plans\", {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n }),\n );\n if (\n value.teamId !== teamId ||\n (await canonicalSha256(value.attachment)) !== (await canonicalSha256(body.attachment))\n )\n throw new OpenPondProtocolError(\n \"post_training_plan_mismatch\",\n \"The retained attachment differs from the reviewed plan.\",\n );\n return value;\n },\n async get(teamId: string, jobId: string) {\n return read(await request(path(jobId), { headers }), teamId, jobId);\n },\n async control(\n teamId: string,\n jobId: string,\n action: \"start\" | \"retry\" | \"cancel\",\n raw: z.input<typeof PostTrainingControlSchema>,\n ) {\n const body = PostTrainingControlSchema.parse(raw);\n const value = await read(\n await request(`${path(jobId)}/${action}`, { method: \"POST\", headers, body: JSON.stringify(body) }),\n teamId,\n jobId,\n );\n if (!value || value.planHash !== body.planHash)\n throw new OpenPondProtocolError(\n \"post_training_control_mismatch\",\n \"Evaluation control did not retain the approved plan.\",\n );\n return value;\n },\n };\n}\n\nexport const HostedTrainingSetupCatalogSchema = z\n .object({\n teamId: Id,\n actorId: Id,\n projectId: Id.nullable(),\n configuration: HostedModelProjectSummarySchema,\n batches: z.array(TaskBatchSchema).max(10_000),\n sources: z.array(LearningSourceSchema).max(10_000),\n definitions: z.array(TaskDefinitionSchema).max(10_000),\n experiments: z\n .array(\n z\n .object({\n id: Id,\n name: z.string().max(500),\n configuration: RunExperimentSchema,\n graders: z\n .array(z.object({ feedbackKey: Id, name: z.string().max(500), ref: Ref }).strict())\n .max(100),\n })\n .strict(),\n )\n .max(10_000),\n })\n .strict();\nexport type HostedTrainingSetupCatalog = z.infer<typeof HostedTrainingSetupCatalogSchema>;\n\nexport const HostedTrainingSetupActionSchema = z.enum([\n \"hardware-catalog\",\n \"gpu-catalog\",\n \"modification-capabilities\",\n \"estimate\",\n \"funding\", \"funding-handoff\",\n \"list-drafts\", \"get-draft\", \"save-draft\", \"archive-draft\",\n \"prepare\",\n \"prepare-draft\",\n \"review-dataset\",\n \"start\",\n \"cancel\",\n \"publish\",\n \"attach\",\n]);\nexport type HostedTrainingSetupAction = z.infer<typeof HostedTrainingSetupActionSchema>;\n\nexport const HostedTrainingPolicyDetailSchema = z\n .object({\n teamId: Id,\n actorId: Id,\n configuration: HostedModelProjectSummarySchema,\n policy: LearningPolicySchema,\n inspection: LearningPolicyInspectionResultSchema,\n iterations: z\n .array(\n z\n .object({\n iteration: LearningIterationSchema,\n evals: PostTrainingSummarySchema.nullable(),\n })\n .strict(),\n )\n .max(100),\n nextCursor: Id.nullable(),\n })\n .strict();\nexport const HostedTrainingPolicyControlSchema = z\n .object({\n id: Id,\n expectedRevision: z.number().int().positive(),\n policyHash: Hash,\n operationId: Id,\n action: z.enum([\"pause\", \"resume\", \"reserve\", \"cancel-iteration\", \"retry-iteration\"]),\n iterationId: Id.optional(),\n iterationRevision: z.number().int().positive().optional(),\n })\n .strict();\nexport type HostedTrainingPolicyControl = z.infer<typeof HostedTrainingPolicyControlSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,+BAAAA,oCAA+D;AAIxE,IAAM,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC3C,IAAM,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB;AAC9C,IAAM,MAAM,EAAE,OAAO,EAAE,IAAI,IAAI,aAAa,KAAK,CAAC,EAAE,OAAO;AACpD,IAAM,+BAA+B,EACzC,OAAO;AAAA,EACN,WAAW,EAAE,QAAQ;AAAA,EACrB,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAI,EAAE,SAAS;AAAA,EACtC,QAAQ,4BAA4B,SAAS;AAC/C,CAAC,EACA,OAAO;AAEH,IAAM,+BAA+B,EACzC,OAAO;AAAA,EACN,eAAe,EAAE,QAAQ,oCAAoC;AAAA,EAC7D,SAAS,EACN,OAAO;AAAA,IACN,MAAM,EAAE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,GAAG,SAAS;AAAA,EACzB,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAC1D,CAAC,EACA,OAAO;","names":["TrainingHandoffOriginSchema"]}
1
+ {"version":3,"sources":["../src/post-training.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport {\n LearningSourceSchema,\n TaskBatchSchema,\n TaskDefinitionSchema,\n LearningPolicySchema,\n LearningPolicyInspectionResultSchema,\n LearningIterationSchema,\n} from \"@openpond/evals/learning\";\nimport { HostedModelProjectSummarySchema } from \"./model-projects.js\";\nimport { AcceptancePlanSchema } from \"@openpond/evals/learning\";\nimport { TrainingHandoffOriginSchema } from \"@openpond/evals/learning\";\nexport { TrainingHandoffOriginSchema, type TrainingHandoffOrigin } from \"@openpond/evals/learning\";\nimport { RunExperimentSchema } from \"./experiment-run-contracts.js\";\nimport { canonicalSha256, OpenPondProtocolError } from \"./protocol.js\";\n\nconst Id = z.string().trim().min(1).max(200);\nconst Hash = z.string().regex(/^[a-f0-9]{64}$/);\nconst Ref = z.object({ id: Id, contentHash: Hash }).strict();\nexport const TrainingHandoffContextSchema = z\n .object({\n available: z.boolean(),\n reason: z.string().max(1000).nullable(),\n origin: TrainingHandoffOriginSchema.nullable(),\n })\n .strict();\nexport type TrainingHandoffContext = z.infer<typeof TrainingHandoffContextSchema>;\nexport const PostTrainingAttachmentSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.postTrainingAttachment.v1\"),\n binding: z\n .object({\n kind: z.enum([\"preparation\", \"policy\"]),\n id: Id,\n revision: z.number().int().positive(),\n contentHash: Hash,\n })\n .strict(),\n projectId: Id.nullable(),\n automatic: z.boolean(),\n maximumSpendUsd: z.number().finite().positive().max(10_000),\n experiments: z\n .array(z.object({ id: Id, configuration: RunExperimentSchema }).strict())\n .min(1)\n .max(20),\n acceptancePlan: AcceptancePlanSchema.nullable(),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (new Set(value.experiments.map((item) => item.id)).size !== value.experiments.length)\n ctx.addIssue({ code: \"custom\", message: \"Attach each evaluation once.\" });\n if (\n value.experiments.reduce((sum, item) => sum + item.configuration.maximumCostUsd, 0) >\n value.maximumSpendUsd + 1e-9\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Attached evaluation budgets exceed the total approved budget.\",\n });\n if (\n value.experiments.some(\n (item) => (item.configuration.request.project?.id ?? null) !== value.projectId,\n )\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Attached experiments must use the training Project.\",\n });\n if (value.acceptancePlan) {\n const checked = new Set(value.acceptancePlan.checks.map((c) => c.id));\n if (value.acceptancePlan.checks.some((c) => !value.experiments.some((m) => m.id === c.id)))\n ctx.addIssue({\n code: \"custom\",\n message: \"Select the frozen Experiment for each acceptance check.\",\n });\n const committed =\n value.acceptancePlan.maximumSpendUsd +\n value.experiments\n .filter((m) => !checked.has(m.id))\n .reduce((sum, m) => sum + m.configuration.maximumCostUsd, 0);\n if (committed > value.maximumSpendUsd + 1e-9)\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Paired acceptance and diagnostic ceilings exceed the approved evaluation budget.\",\n });\n }\n });\nexport type PostTrainingAttachment = z.infer<typeof PostTrainingAttachmentSchema>;\n/** Target-independent recipe pins keep the paired baseline/candidate check on\n * the same released data, case order, settings and graders. */\nexport function postTrainingRecipe(\n configuration: PostTrainingAttachment[\"experiments\"][number][\"configuration\"],\n) {\n const {\n modelId: _model,\n candidate: _candidate,\n ...settings\n } = configuration.request.policy.kind === \"fixture\"\n ? { modelId: null, candidate: null, ...configuration.request.policy }\n : configuration.request.policy;\n void _model;\n void _candidate;\n if (\"modelConfigurationHash\" in settings)\n delete (settings as { modelConfigurationHash?: string }).modelConfigurationHash;\n return {\n dataset: {\n id: configuration.request.taskset.id,\n contentHash: configuration.request.taskset.contentHash,\n },\n populationHash: contentHash(\n configuration.request.population.map((m) => ({\n caseId: m.taskId,\n seed: m.seed,\n fixtureId: m.fixtureId,\n })),\n ),\n executionHash: contentHash({ settings, graders: configuration.graders ?? null }),\n };\n}\nexport const PostTrainingQualificationSchema = z\n .object({\n baseline: Ref,\n checks: z\n .array(\n z\n .object({\n id: Id,\n sourceRunId: Id,\n sourceManifestHash: Hash,\n targetConfigurationHash: Hash,\n executionHash: Hash,\n populationHash: Hash,\n evaluator: Ref,\n feedbackKey: Id,\n output: z.enum([\"boolean\", \"score\"]),\n unit: z.string().min(1).max(80),\n })\n .strict(),\n )\n .min(1)\n .max(100),\n })\n .strict();\nexport const PostTrainingStateSchema = z.enum([\n \"waiting_for_training\",\n \"ready\",\n \"preparing\",\n \"queued\",\n \"running\",\n \"cleaning\",\n \"completed\",\n \"failed\",\n \"blocked\",\n \"cancelled\",\n \"budget_exhausted\",\n]);\nexport const PostTrainingSummarySchema = z\n .object({\n schemaVersion: z.literal(\"openpond.postTrainingSummary.v1\"),\n id: Id,\n teamId: Id,\n jobId: Id,\n revision: z.number().int().positive(),\n planHash: Hash,\n automatic: z.boolean(),\n candidate: Ref.nullable(),\n state: PostTrainingStateSchema,\n total: z.number().int().positive(),\n completed: z.number().int().nonnegative(),\n failed: z.number().int().nonnegative(),\n requiredOutcome: z.enum([\"none\", \"pending\", \"passed\", \"failed\", \"blocked\"]),\n reason: z.string().max(500).nullable(),\n groupId: Id.nullable(),\n experimentIds: z.array(Id).max(20),\n updatedAt: z.iso.datetime(),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (value.completed + value.failed > value.total)\n ctx.addIssue({ code: \"custom\", message: \"Evaluation totals are inconsistent.\" });\n if (\n [\"preparing\", \"queued\", \"running\", \"cleaning\", \"completed\"].includes(value.state) &&\n !value.candidate\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Evaluation execution requires the exact trained candidate.\",\n });\n });\nexport type PostTrainingSummary = z.infer<typeof PostTrainingSummarySchema>;\nexport const PostTrainingControlSchema = z\n .object({ operationId: Id, expectedRevision: z.number().int().positive(), planHash: Hash })\n .strict();\nexport const AttachPostTrainingSchema = z\n .object({ operationId: Id, attachment: PostTrainingAttachmentSchema })\n .strict();\nexport const PostTrainingPlanSchema = z\n .object({\n id: Id,\n teamId: Id,\n ownerUserId: Id,\n attachment: PostTrainingAttachmentSchema,\n qualification: PostTrainingQualificationSchema.nullable(),\n contentHash: Hash,\n createdAt: z.iso.datetime(),\n })\n .strict();\nexport type PostTrainingPlan = z.infer<typeof PostTrainingPlanSchema>;\nexport function verifyPostTrainingPlan(raw: unknown): PostTrainingPlan {\n const plan = PostTrainingPlanSchema.parse(raw);\n if (\n plan.contentHash !==\n contentHash({ attachment: plan.attachment, qualification: plan.qualification })\n )\n throw new Error(\"The retained evaluation attachment or qualification changed.\");\n return plan;\n}\nexport function postTrainingActive(summary: PostTrainingSummary | null | undefined) {\n return Boolean(summary && [\"preparing\", \"queued\", \"running\", \"cleaning\"].includes(summary.state));\n}\n\n/** Read/setup are configuration-only. Manual start authorizes exactly the\n * retained candidate, plan and revision. A retry never launches training. */\nexport function createPostTrainingClient(input: {\n request: (path: string, init?: RequestInit) => Promise<unknown>;\n}) {\n const { request } = input;\n // These public evaluation routes consume ordinary JSON, independently of\n // the versioned Training V2 job routes used by the parent factory.\n const headers = { accept: \"application/json\", \"content-type\": \"application/json\" };\n const path = (jobId: string) =>\n `/v1/training/jobs/${encodeURIComponent(Id.parse(jobId))}/post-training`;\n async function read(raw: unknown, teamId: string, jobId: string) {\n if (raw === null) return null;\n const value = PostTrainingSummarySchema.parse(raw);\n if (value.teamId !== teamId || value.jobId !== jobId)\n throw new OpenPondProtocolError(\n \"post_training_scope_mismatch\",\n \"The evaluation summary belongs to another run or workspace.\",\n );\n return value;\n }\n return {\n async attach(teamId: string, raw: z.input<typeof AttachPostTrainingSchema>) {\n const body = AttachPostTrainingSchema.parse(raw);\n const value = verifyPostTrainingPlan(\n await request(\"/v1/training/post-training-plans\", {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n }),\n );\n if (\n value.teamId !== teamId ||\n (await canonicalSha256(value.attachment)) !== (await canonicalSha256(body.attachment))\n )\n throw new OpenPondProtocolError(\n \"post_training_plan_mismatch\",\n \"The retained attachment differs from the reviewed plan.\",\n );\n return value;\n },\n async get(teamId: string, jobId: string) {\n return read(await request(path(jobId), { headers }), teamId, jobId);\n },\n async control(\n teamId: string,\n jobId: string,\n action: \"start\" | \"retry\" | \"cancel\",\n raw: z.input<typeof PostTrainingControlSchema>,\n ) {\n const body = PostTrainingControlSchema.parse(raw);\n const value = await read(\n await request(`${path(jobId)}/${action}`, { method: \"POST\", headers, body: JSON.stringify(body) }),\n teamId,\n jobId,\n );\n if (!value || value.planHash !== body.planHash)\n throw new OpenPondProtocolError(\n \"post_training_control_mismatch\",\n \"Evaluation control did not retain the approved plan.\",\n );\n return value;\n },\n };\n}\n\nexport const HostedTrainingSetupCatalogSchema = z\n .object({\n teamId: Id,\n actorId: Id,\n projectId: Id.nullable(),\n configuration: HostedModelProjectSummarySchema,\n batches: z.array(TaskBatchSchema).max(10_000),\n sources: z.array(LearningSourceSchema).max(10_000),\n definitions: z.array(TaskDefinitionSchema).max(10_000),\n experiments: z\n .array(\n z\n .object({\n id: Id,\n name: z.string().max(500),\n configuration: RunExperimentSchema,\n graders: z\n .array(z.object({ feedbackKey: Id, name: z.string().max(500), ref: Ref }).strict())\n .max(100),\n })\n .strict(),\n )\n .max(10_000),\n })\n .strict();\nexport type HostedTrainingSetupCatalog = z.infer<typeof HostedTrainingSetupCatalogSchema>;\n\nexport const HostedTrainingSetupActionSchema = z.enum([\n \"hardware-catalog\",\n \"gpu-catalog\",\n \"modification-capabilities\",\n \"estimate\",\n \"funding\", \"funding-handoff\",\n \"list-drafts\", \"get-draft\", \"save-draft\", \"archive-draft\",\n \"prepare\",\n \"prepare-draft\",\n \"save-experiment-learning\",\n \"review-dataset\",\n \"start\",\n \"cancel\",\n \"publish\",\n \"attach\",\n]);\nexport type HostedTrainingSetupAction = z.infer<typeof HostedTrainingSetupActionSchema>;\n\nexport const HostedTrainingPolicyDetailSchema = z\n .object({\n teamId: Id,\n actorId: Id,\n configuration: HostedModelProjectSummarySchema,\n policy: LearningPolicySchema,\n inspection: LearningPolicyInspectionResultSchema,\n iterations: z\n .array(\n z\n .object({\n iteration: LearningIterationSchema,\n evals: PostTrainingSummarySchema.nullable(),\n })\n .strict(),\n )\n .max(100),\n nextCursor: Id.nullable(),\n })\n .strict();\nexport const HostedTrainingPolicyControlSchema = z\n .object({\n id: Id,\n expectedRevision: z.number().int().positive(),\n policyHash: Hash,\n operationId: Id,\n action: z.enum([\"pause\", \"resume\", \"reserve\", \"cancel-iteration\", \"retry-iteration\"]),\n iterationId: Id.optional(),\n iterationRevision: z.number().int().positive().optional(),\n })\n .strict();\nexport type HostedTrainingPolicyControl = z.infer<typeof HostedTrainingPolicyControlSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,+BAAAA,oCAA+D;AAIxE,IAAM,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC3C,IAAM,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB;AAC9C,IAAM,MAAM,EAAE,OAAO,EAAE,IAAI,IAAI,aAAa,KAAK,CAAC,EAAE,OAAO;AACpD,IAAM,+BAA+B,EACzC,OAAO;AAAA,EACN,WAAW,EAAE,QAAQ;AAAA,EACrB,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAI,EAAE,SAAS;AAAA,EACtC,QAAQ,4BAA4B,SAAS;AAC/C,CAAC,EACA,OAAO;AAEH,IAAM,+BAA+B,EACzC,OAAO;AAAA,EACN,eAAe,EAAE,QAAQ,oCAAoC;AAAA,EAC7D,SAAS,EACN,OAAO;AAAA,IACN,MAAM,EAAE,KAAK,CAAC,eAAe,QAAQ,CAAC;AAAA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BAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAC1D,CAAC,EACA,OAAO;","names":["TrainingHandoffOriginSchema"]}
package/dist/learning.js CHANGED
@@ -95,8 +95,8 @@ function createHostedLearningPolicyContent(input) {
95
95
  const refs = applyModel ? hostedLearningPolicyReferences(project) : null;
96
96
  const method = applyModel ? project.trainingSetup.recipe?.method : previous?.training.method;
97
97
  const trigger = settings.trigger ?? (settings.scheduled ? { kind: "schedule", intervalSeconds: settings.intervalSeconds } : { kind: "manual" });
98
- if (settings.enabled && method !== "grpo") {
99
- throw new LearningDomainError("learning_training_method_unsupported", 422, "Hosted continual learning currently supports GRPO.");
98
+ if (settings.enabled && method !== "grpo" && method !== "sft") {
99
+ throw new LearningDomainError("learning_training_method_unsupported", 422, "Hosted continual learning supports reviewed SFT and GRPO.");
100
100
  }
101
101
  return LearningPolicyContentSchema.parse({
102
102
  schemaVersion: "openpond.learningPolicy.v1",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/learning.ts","../src/model-learning-policy.ts","../src/grader-inspection.ts","../src/grader-feedback-key.ts","../src/learning-correction-metrics.ts"],"sourcesContent":["export * from \"@openpond/evals/learning\";\nexport * from \"@openpond/evals/rewards\";\nexport * from \"./learning-credentials.js\";\nexport * from \"./learning-client.js\";\nexport * from \"./model-learning-policy.js\";\n\nexport * from \"./grader-inspection.js\";\n\nexport * from \"./grader-feedback-key.js\";\nexport * from \"./learning-correction-metrics.js\";\n","import { LearningDomainError, LearningPolicyContentSchema, LearningSourceContentSchema, learningRef, sameLearningRef, sealLearningContent, type TaskDefinition, type LearningPolicy, type LearningRevisionRef } from \"@openpond/evals/learning\";\nimport { contentHash } from \"@openpond/harness\";\n\nimport type { HostedModelProjectSummary } from \"./model-projects.js\";\nimport { ModelInitialLearningSchema, type ModelInitialLearning } from \"./model-learning-intent.js\";\n\n/** Compile the simple creation choice into exact source and policy releases.\n * Hosts commit these with the new Model and its idempotency receipt. */\nexport function initialHostedModelLearning(input: { project: HostedModelProjectSummary; definition: TaskDefinition; learning: ModelInitialLearning }) {\n const learning = ModelInitialLearningSchema.parse(input.learning);\n const { project, definition } = input;\n if (!project.trainingSetup.rewardBindingRef || !sameLearningRef(definition.rewardBinding, project.trainingSetup.rewardBindingRef)) throw new LearningDomainError(\"learning_policy_binding_mismatch\", 422, \"The task format must use the Model's selected grader.\");\n const source = LearningSourceContentSchema.parse({ schemaVersion: \"openpond.learningSource.v1\", id: `model-source-${contentHash([project.portableProjectId, learningRef(definition)])}`,\n revision: 1, name: `${project.name} tasks`, kind: \"direct\", taskDefinition: learningRef(definition), enabled: true,\n allowedSplits: [\"train\", \"validation\", \"test\", \"frozen_eval\"], mapping: null, adapterVersion: null });\n const policy = createHostedLearningPolicyContent({ project, previous: null, policyId: `model-policy-${contentHash(project.portableProjectId)}`,\n applyModelConfiguration: true, sources: [learningRef(sealLearningContent(source))], taskDefinition: learningRef(definition),\n settings: { ...hostedLearningPolicyDefaults(project, null), enabled: true, scheduled: true,\n trigger: learning.mode === \"nightly\" ? { kind: \"nightly\", localTime: learning.localTime, timeZone: learning.timeZone } : { kind: \"approved_count\" },\n minimumApprovedExamples: learning.minimumTasks, maxBatchExamples: learning.minimumTasks,\n maxIterationSpendUsd: learning.maximumSpendUsd, maxDailySpendUsd: learning.maximumDailySpendUsd,\n cooldownSeconds: 0, maxBacklogExamples: Math.max(1_000, learning.minimumTasks * 10),\n } });\n return { source, policy };\n}\n\n/** Shared starting values for both Model clients. Existing policies retain\n * their exact limits; opening settings must never silently increase spending. */\nexport function hostedLearningPolicyDefaults(project: HostedModelProjectSummary, policy: LearningPolicy | null) {\n const maximumSpend = policy?.limits.maxIterationSpendUsd ?? project.trainingSetup.preferredMaximumSpendUsd ?? 1;\n return {\n enabled: policy?.enabled ?? false,\n scheduled: Boolean(policy && [\"schedule\", \"nightly\", \"approved_count\"].includes(policy.trigger.kind)),\n intervalSeconds: policy?.trigger.kind === \"schedule\" ? policy.trigger.intervalSeconds : 86_400,\n humanReviewRequired: policy?.admission.mode !== \"qualified_automatic\",\n minimumApprovedExamples: policy?.admission.minimumApprovedExamples ?? 10,\n maxBatchExamples: policy?.limits.maxBatchExamples ?? 10,\n maxIterationSpendUsd: maximumSpend,\n maxDailySpendUsd: policy?.limits.maxDailySpendUsd ?? maximumSpend,\n cooldownSeconds: policy?.limits.cooldownSeconds ?? 3_600,\n maxRetries: policy?.limits.maxRetries ?? 0,\n maxBacklogExamples: policy?.limits.maxBacklogExamples ?? 1_000,\n };\n}\n\nexport interface HostedLearningPolicySettings {\n enabled: boolean;\n scheduled: boolean;\n intervalSeconds: number;\n trigger?: Exclude<LearningPolicy[\"trigger\"], { kind: \"upstream_accepted\" }>;\n humanReviewRequired: boolean;\n minimumApprovedExamples: number;\n maxBatchExamples: number;\n maxIterationSpendUsd: number;\n maxDailySpendUsd: number;\n cooldownSeconds: number;\n maxRetries: number;\n maxBacklogExamples: number;\n}\n\n/** Compile reviewed settings without following mutable Model configuration\n * unless the caller explicitly chooses to apply it. Publication still owns\n * authorization, revision comparison and source/qualification validation. */\nexport function createHostedLearningPolicyContent(input: {\n project: HostedModelProjectSummary;\n previous: LearningPolicy | null;\n policyId: string;\n applyModelConfiguration: boolean;\n sources: LearningRevisionRef[];\n taskDefinition: LearningRevisionRef;\n settings: HostedLearningPolicySettings;\n}) {\n const { project, previous, settings } = input;\n if (previous && (previous.id !== input.policyId || previous.modelProjectId !== project.portableProjectId || previous.executionOwner !== \"hosted\")) {\n throw new LearningDomainError(\"learning_policy_model_mismatch\", 422, \"Learning settings must belong to this hosted Model.\");\n }\n const applyModel = input.applyModelConfiguration || !previous;\n const refs = applyModel ? hostedLearningPolicyReferences(project) : null;\n const method = applyModel ? project.trainingSetup.recipe?.method : previous?.training.method;\n const trigger = settings.trigger ?? (settings.scheduled ? { kind: \"schedule\" as const, intervalSeconds: settings.intervalSeconds } : { kind: \"manual\" as const });\n if (settings.enabled && method !== \"grpo\") {\n throw new LearningDomainError(\"learning_training_method_unsupported\", 422, \"Hosted continual learning currently supports GRPO.\");\n }\n return LearningPolicyContentSchema.parse({\n schemaVersion: \"openpond.learningPolicy.v1\", id: input.policyId, revision: (previous?.revision ?? 0) + 1,\n modelProjectId: project.portableProjectId, executionOwner: \"hosted\", enabled: settings.enabled,\n sources: input.sources, taskDefinition: input.taskDefinition,\n rewardBinding: applyModel ? project.trainingSetup.rewardBindingRef : previous?.rewardBinding,\n admission: { mode: settings.humanReviewRequired ? \"human\" : \"qualified_automatic\",\n qualification: settings.humanReviewRequired ? null : previous?.admission.qualification ?? null,\n minimumApprovedExamples: settings.minimumApprovedExamples },\n trigger,\n trainingParent: refs?.trainingParent ?? previous?.trainingParent,\n teacher: previous?.teacher ?? null,\n training: { method, recipe: refs?.recipe ?? previous?.training.recipe,\n retentionEvaluation: refs?.retentionEvaluation ?? previous?.training.retentionEvaluation,\n replayBatches: previous?.training.replayBatches ?? [] },\n limits: { maxIterationSpendUsd: settings.maxIterationSpendUsd, maxDailySpendUsd: settings.maxDailySpendUsd,\n cooldownSeconds: settings.cooldownSeconds, maxRetries: settings.maxRetries,\n maxBatchExamples: settings.maxBatchExamples, maxBacklogExamples: settings.maxBacklogExamples },\n automation: { collect: false, train: trigger.kind !== \"manual\", accept: false, serve: false },\n acceptance: previous?.acceptance ?? { minimumScore: 0, maximumRetentionRegression: 0, requireImprovement: true, rollbackVersion: null },\n });\n}\n\n/** Bind a reviewed hosted Model configuration before asynchronous preparation.\n * Keep the established recipe identity: its id binds the whole Model revision,\n * including Harness and retention selections, while its hash binds the recipe.\n * Callers must obtain the summary from the authenticated Model API. */\nexport function hostedLearningPolicyReferences(project: HostedModelProjectSummary) {\n const setup = project.trainingSetup;\n const base = setup.baseModel ?? project.defaultBaseModel;\n if (!setup.recipe || !base || !setup.evaluationTasksetRef) {\n throw new LearningDomainError(\"learning_model_configuration_incomplete\", 422,\n \"Select a training recipe, starting model and retained evaluation before enabling hosted learning.\");\n }\n return {\n recipe: { id: `model-recipe-${project.etag}`, contentHash: contentHash(setup.recipe) },\n trainingParent: { id: base.modelId, contentHash: contentHash(base) },\n retentionEvaluation: { id: setup.evaluationTasksetRef.id, contentHash: setup.evaluationTasksetRef.contentHash },\n };\n}\n","import { z } from \"zod\";\nimport { RewardReleaseSchema } from \"@openpond/evals/rewards\";\nconst Id = z.string().trim().min(1).max(240);\nexport const GraderCatalogQuerySchema = z.object({ projectId: Id.optional(), search: z.string().max(300).optional(), kind: z.string().max(100).optional(), sort: z.enum([\"name\", \"type\", \"version\", \"projects\", \"datasets\", \"runs\"]).optional(), direction: z.enum([\"asc\", \"desc\"]).optional(), after: z.string().max(3000).optional(), limit: z.number().int().min(1).max(100).default(30) }).strict();\nexport const GraderCatalogPageSchema = z.object({ teamId: Id, items: z.array(z.object({ reward: RewardReleaseSchema, projects: z.number().int().nonnegative(), datasets: z.number().int().nonnegative(), runs: z.number().int().nonnegative() }).strict()).max(100), nextCursor: z.string().nullable() }).strict();\nexport const GraderVersionsPageSchema = z.object({ teamId: Id, id: Id, items: z.array(RewardReleaseSchema).max(100), nextRevision: z.number().int().positive().nullable() }).strict();\nexport const GraderUsageQuerySchema = z.object({ section: z.enum([\"projects\", \"datasets\", \"runs\"]), after: Id.optional(), limit: z.number().int().min(1).max(100).default(25) }).strict();\nexport const GraderUsagePageSchema = z.object({ teamId: Id, id: Id, section: GraderUsageQuerySchema.shape.section, items: z.array(z.union([\n z.object({ id: Id, name: z.string(), graderRevisions: z.array(z.number().int().positive()), archived: z.boolean() }).strict(),\n z.object({ id: Id, name: z.string(), revision: z.number().int().positive(), graderRevisions: z.array(z.number().int().positive()) }).strict(),\n z.object({ id: Id, name: z.string(), status: z.string() }).strict(),\n])).max(100), nextCursor: Id.nullable() }).strict();\nexport class OpenPondGraderInspectionClient {\n private readonly baseUrl: string;\n constructor(private readonly options: { baseUrl: string; apiKey: string; teamId: string; fetch?: typeof fetch }) {\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.apiKey.trim() || !options.teamId.trim()) throw new Error(\"A clean API origin and workspace credentials are required.\");\n this.baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n async catalog(value: z.input<typeof GraderCatalogQuerySchema> = {}, signal?: AbortSignal) {\n const query = GraderCatalogQuerySchema.parse(value);\n const page = GraderCatalogPageSchema.parse(await this.read(\"\", query, signal));\n if (page.teamId !== this.options.teamId || page.items.length > query.limit || new Set(page.items.map(item => item.reward.id)).size !== page.items.length) throw new Error(\"Grader catalog differs from its requested workspace or bounds.\");\n return page;\n }\n async versions(id: string, query: { beforeRevision?: number; limit?: number } = {}, signal?: AbortSignal) {\n const options = z.object({ beforeRevision: z.number().int().positive().optional(), limit: z.number().int().min(1).max(100).default(25) }).strict().parse(query);\n const page = GraderVersionsPageSchema.parse(await this.read(`/${encodeURIComponent(Id.parse(id))}/versions`, options, signal));\n if (page.teamId !== this.options.teamId || page.id !== id || page.items.length > options.limit || page.items.some((item, index) => item.id !== id || options.beforeRevision && item.revision >= options.beforeRevision || index > 0 && item.revision >= page.items[index - 1]!.revision)) throw new Error(\"Grader versions differ from their requested identity or revision order.\");\n return page;\n }\n async usage(id: string, value: z.input<typeof GraderUsageQuerySchema>, signal?: AbortSignal) {\n const query = GraderUsageQuerySchema.parse(value);\n const page = GraderUsagePageSchema.parse(await this.read(`/${encodeURIComponent(Id.parse(id))}/usage`, query, signal));\n if (page.teamId !== this.options.teamId || page.id !== id || page.section !== query.section || page.items.length > query.limit) throw new Error(\"Grader usage differs from its requested workspace, identity or bounds.\");\n return page;\n }\n private async read(path: string, query: Record<string, unknown>, signal?: AbortSignal) {\n const params = new URLSearchParams(Object.entries(query).filter(([, value]) => value !== undefined).map(([key, value]) => [key, String(value)]));\n const response = await (this.options.fetch ?? fetch)(`${this.baseUrl}/v1/learning/read/graders${path}?${params}`, { signal, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"X-OpenPond-Team-Id\": this.options.teamId, Accept: \"application/json\" } });\n const value: unknown = await response.json();\n if (!response.ok) throw new Error(z.object({ error: z.string() }).parse(value).error);\n return value;\n }\n}\n","import { contentHash } from \"@openpond/harness\";\n\n/** Draft presentation default. Published keys must retain their released value. */\nexport function graderFeedbackKeyFromName(name: string, rewardId: string): string {\n const slug = name.normalize(\"NFKD\").toLowerCase().replace(/[^a-z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\");\n const prefix = /^[a-z]/.test(slug) ? slug : `grader_${slug}`;\n return `${(prefix || \"grader\").slice(0, 55).replace(/_+$/g, \"\")}_${contentHash(rewardId).slice(0, 24)}`;\n}\n","import { z } from \"zod\";\nimport { CorrectionVerificationPlanContentSchema, CorrectionVerificationPlanSchema, CorrectionOpportunitySchema, CorrectionMetricSummarySchema, CorrectionMetricObservationSchema, assertLearningRequestJson } from \"@openpond/evals/learning\";\nimport { OpenPondLearningError, readBoundedLearningResponse, type LearningRequestOptions } from \"./learning-client.js\";\nexport { CorrectionVerificationPlanSchema, CorrectionMetricSummarySchema, CorrectionMetricObservationSchema } from \"@openpond/evals/learning\";\nexport type { CorrectionVerificationPlan, CorrectionMetricSummary, CorrectionMetricObservation } from \"@openpond/evals/learning\";\nconst id = z.string().trim().min(1).max(500);\nconst ref = z.object({ id, contentHash: z.string().regex(/^[a-f0-9]{64}$/) }).strict();\nexport const CorrectionMetricsReadSchema = z.object({ teamId: id, modelId: id, runId: id.optional(), from: z.string().datetime().optional(), to: z.string().datetime().optional() }).strict();\nexport const CorrectionMetricsCommandSchema = z.discriminatedUnion(\"action\", [\n z.object({ action: z.literal(\"declare_verification\"), teamId: id, operationId: id,\n plan: z.object({\n modelId: CorrectionVerificationPlanContentSchema.shape.modelId,\n classification: CorrectionVerificationPlanContentSchema.shape.classification,\n feedback: CorrectionVerificationPlanContentSchema.shape.feedback,\n evidence: CorrectionVerificationPlanContentSchema.shape.evidence,\n trainingJobId: CorrectionVerificationPlanContentSchema.shape.trainingJobId,\n checkpoint: CorrectionVerificationPlanContentSchema.shape.checkpoint,\n artifact: CorrectionVerificationPlanContentSchema.shape.artifact,\n taskset: CorrectionVerificationPlanContentSchema.shape.taskset,\n checks: CorrectionVerificationPlanContentSchema.shape.checks,\n baselineOperationId: CorrectionVerificationPlanContentSchema.shape.baselineOperationId,\n candidateOperationId: CorrectionVerificationPlanContentSchema.shape.candidateOperationId,\n criterion: CorrectionVerificationPlanContentSchema.shape.criterion,\n }).strict() }).strict(),\n z.object({ action: z.literal(\"link_live_opportunity\"), teamId: id, operationId: id, correction: ref, inferenceRequestId: id,\n grade: z.object({ id, revision: z.number().int().positive() }).strict(), checkIds: z.array(id).min(1).max(1000) }).strict(),\n]);\nexport const CorrectionMetricsDetailSchema = z.object({ summary: CorrectionMetricSummarySchema.nullable(), observations: z.array(CorrectionMetricObservationSchema).max(1000) }).strict();\nexport type CorrectionMetricsRead = z.infer<typeof CorrectionMetricsReadSchema>;\nexport type CorrectionMetricsCommand = z.infer<typeof CorrectionMetricsCommandSchema>;\nexport class OpenPondCorrectionMetricsClient {\n private readonly options: { baseUrl: string; apiKey: string; fetch?: typeof globalThis.fetch };\n constructor(options: { baseUrl: string; apiKey: string; fetch?: typeof globalThis.fetch }) {\n if (!options.apiKey.trim()) throw new Error(\"Learning API key is required.\");\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash)\n throw new Error(\"Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.\");\n this.options = { ...options, baseUrl: url.toString().replace(/\\/+$/, \"\") };\n }\n private async request(path: string, teamId: string, init: RequestInit) {\n const response = await (this.options.fetch ?? globalThis.fetch)(`${this.options.baseUrl}${path}`, {\n ...init, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"Content-Type\": \"application/json\", Accept: \"application/json\", \"X-OpenPond-Team-Id\": teamId },\n });\n let payload: unknown;\n try { payload = await readBoundedLearningResponse(response); }\n catch (error) {\n if (error instanceof OpenPondLearningError) throw error;\n throw new OpenPondLearningError(response.ok ? 502 : response.status, \"invalid_response\", \"Correction metrics returned an invalid response.\", null);\n }\n if (!response.ok) {\n const error = z.object({ code: z.string().optional(), error: z.string().optional() }).passthrough().safeParse(payload);\n throw new OpenPondLearningError(response.status, error.success ? error.data.code ?? \"correction_request_failed\" : \"correction_request_failed\",\n error.success ? error.data.error ?? `Correction metrics request failed (${response.status}).` : `Correction metrics request failed (${response.status}).`, payload);\n }\n return payload;\n }\n async read(input: CorrectionMetricsRead, options: LearningRequestOptions = {}) {\n const query = CorrectionMetricsReadSchema.parse(input);\n const result = CorrectionMetricsDetailSchema.parse(await this.request(`/v1/learning/corrections?query=${encodeURIComponent(JSON.stringify(query))}`, query.teamId, { method: \"GET\", signal: options.signal }));\n if (result.summary && (result.summary.scope.teamId !== query.teamId || result.summary.scope.modelId !== query.modelId || query.runId && result.summary.scope.runId !== query.runId)\n || result.observations.some(observation => observation.modelId !== query.modelId || query.runId && observation.trainingJobId !== query.runId))\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction metrics did not match the requested workspace, Model or run.\", null);\n return result;\n }\n async command(input: CorrectionMetricsCommand, options: LearningRequestOptions = {}) {\n const command = CorrectionMetricsCommandSchema.parse(input);\n assertLearningRequestJson(command);\n const payload = await this.request(\"/v1/learning/corrections\", command.teamId, { method: \"POST\", body: JSON.stringify(command), signal: options.signal });\n if (command.action === \"declare_verification\") {\n const result = CorrectionVerificationPlanSchema.parse(payload);\n if (result.teamId !== command.teamId || result.modelId !== command.plan.modelId || result.trainingJobId !== command.plan.trainingJobId)\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction declaration did not match the requested workspace, Model or run.\", null);\n return result;\n }\n const result = CorrectionOpportunitySchema.parse(payload);\n if (result.correction.id !== command.correction.id || result.correction.contentHash !== command.correction.contentHash || result.attempt.id !== command.inferenceRequestId)\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction opportunity did not match the declared correction and serving request.\", null);\n return result;\n }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AAO;AAAA,EACT;AACF;","names":["id","value","z","CorrectionVerificationPlanSchema","CorrectionMetricSummarySchema","CorrectionMetricObservationSchema","z","result"]}
1
+ {"version":3,"sources":["../src/learning.ts","../src/model-learning-policy.ts","../src/grader-inspection.ts","../src/grader-feedback-key.ts","../src/learning-correction-metrics.ts"],"sourcesContent":["export * from \"@openpond/evals/learning\";\nexport * from \"@openpond/evals/rewards\";\nexport * from \"./learning-credentials.js\";\nexport * from \"./learning-client.js\";\nexport * from \"./model-learning-policy.js\";\n\nexport * from \"./grader-inspection.js\";\n\nexport * from \"./grader-feedback-key.js\";\nexport * from \"./learning-correction-metrics.js\";\n","import { LearningDomainError, LearningPolicyContentSchema, LearningSourceContentSchema, learningRef, sameLearningRef, sealLearningContent, type TaskDefinition, type LearningPolicy, type LearningRevisionRef } from \"@openpond/evals/learning\";\nimport { contentHash } from \"@openpond/harness\";\n\nimport type { HostedModelProjectSummary } from \"./model-projects.js\";\nimport { ModelInitialLearningSchema, type ModelInitialLearning } from \"./model-learning-intent.js\";\n\n/** Compile the simple creation choice into exact source and policy releases.\n * Hosts commit these with the new Model and its idempotency receipt. */\nexport function initialHostedModelLearning(input: { project: HostedModelProjectSummary; definition: TaskDefinition; learning: ModelInitialLearning }) {\n const learning = ModelInitialLearningSchema.parse(input.learning);\n const { project, definition } = input;\n if (!project.trainingSetup.rewardBindingRef || !sameLearningRef(definition.rewardBinding, project.trainingSetup.rewardBindingRef)) throw new LearningDomainError(\"learning_policy_binding_mismatch\", 422, \"The task format must use the Model's selected grader.\");\n const source = LearningSourceContentSchema.parse({ schemaVersion: \"openpond.learningSource.v1\", id: `model-source-${contentHash([project.portableProjectId, learningRef(definition)])}`,\n revision: 1, name: `${project.name} tasks`, kind: \"direct\", taskDefinition: learningRef(definition), enabled: true,\n allowedSplits: [\"train\", \"validation\", \"test\", \"frozen_eval\"], mapping: null, adapterVersion: null });\n const policy = createHostedLearningPolicyContent({ project, previous: null, policyId: `model-policy-${contentHash(project.portableProjectId)}`,\n applyModelConfiguration: true, sources: [learningRef(sealLearningContent(source))], taskDefinition: learningRef(definition),\n settings: { ...hostedLearningPolicyDefaults(project, null), enabled: true, scheduled: true,\n trigger: learning.mode === \"nightly\" ? { kind: \"nightly\", localTime: learning.localTime, timeZone: learning.timeZone } : { kind: \"approved_count\" },\n minimumApprovedExamples: learning.minimumTasks, maxBatchExamples: learning.minimumTasks,\n maxIterationSpendUsd: learning.maximumSpendUsd, maxDailySpendUsd: learning.maximumDailySpendUsd,\n cooldownSeconds: 0, maxBacklogExamples: Math.max(1_000, learning.minimumTasks * 10),\n } });\n return { source, policy };\n}\n\n/** Shared starting values for both Model clients. Existing policies retain\n * their exact limits; opening settings must never silently increase spending. */\nexport function hostedLearningPolicyDefaults(project: HostedModelProjectSummary, policy: LearningPolicy | null) {\n const maximumSpend = policy?.limits.maxIterationSpendUsd ?? project.trainingSetup.preferredMaximumSpendUsd ?? 1;\n return {\n enabled: policy?.enabled ?? false,\n scheduled: Boolean(policy && [\"schedule\", \"nightly\", \"approved_count\"].includes(policy.trigger.kind)),\n intervalSeconds: policy?.trigger.kind === \"schedule\" ? policy.trigger.intervalSeconds : 86_400,\n humanReviewRequired: policy?.admission.mode !== \"qualified_automatic\",\n minimumApprovedExamples: policy?.admission.minimumApprovedExamples ?? 10,\n maxBatchExamples: policy?.limits.maxBatchExamples ?? 10,\n maxIterationSpendUsd: maximumSpend,\n maxDailySpendUsd: policy?.limits.maxDailySpendUsd ?? maximumSpend,\n cooldownSeconds: policy?.limits.cooldownSeconds ?? 3_600,\n maxRetries: policy?.limits.maxRetries ?? 0,\n maxBacklogExamples: policy?.limits.maxBacklogExamples ?? 1_000,\n };\n}\n\nexport interface HostedLearningPolicySettings {\n enabled: boolean;\n scheduled: boolean;\n intervalSeconds: number;\n trigger?: Exclude<LearningPolicy[\"trigger\"], { kind: \"upstream_accepted\" }>;\n humanReviewRequired: boolean;\n minimumApprovedExamples: number;\n maxBatchExamples: number;\n maxIterationSpendUsd: number;\n maxDailySpendUsd: number;\n cooldownSeconds: number;\n maxRetries: number;\n maxBacklogExamples: number;\n}\n\n/** Compile reviewed settings without following mutable Model configuration\n * unless the caller explicitly chooses to apply it. Publication still owns\n * authorization, revision comparison and source/qualification validation. */\nexport function createHostedLearningPolicyContent(input: {\n project: HostedModelProjectSummary;\n previous: LearningPolicy | null;\n policyId: string;\n applyModelConfiguration: boolean;\n sources: LearningRevisionRef[];\n taskDefinition: LearningRevisionRef;\n settings: HostedLearningPolicySettings;\n}) {\n const { project, previous, settings } = input;\n if (previous && (previous.id !== input.policyId || previous.modelProjectId !== project.portableProjectId || previous.executionOwner !== \"hosted\")) {\n throw new LearningDomainError(\"learning_policy_model_mismatch\", 422, \"Learning settings must belong to this hosted Model.\");\n }\n const applyModel = input.applyModelConfiguration || !previous;\n const refs = applyModel ? hostedLearningPolicyReferences(project) : null;\n const method = applyModel ? project.trainingSetup.recipe?.method : previous?.training.method;\n const trigger = settings.trigger ?? (settings.scheduled ? { kind: \"schedule\" as const, intervalSeconds: settings.intervalSeconds } : { kind: \"manual\" as const });\n if (settings.enabled && method !== \"grpo\" && method !== \"sft\") {\n throw new LearningDomainError(\"learning_training_method_unsupported\", 422, \"Hosted continual learning supports reviewed SFT and GRPO.\");\n }\n return LearningPolicyContentSchema.parse({\n schemaVersion: \"openpond.learningPolicy.v1\", id: input.policyId, revision: (previous?.revision ?? 0) + 1,\n modelProjectId: project.portableProjectId, executionOwner: \"hosted\", enabled: settings.enabled,\n sources: input.sources, taskDefinition: input.taskDefinition,\n rewardBinding: applyModel ? project.trainingSetup.rewardBindingRef : previous?.rewardBinding,\n admission: { mode: settings.humanReviewRequired ? \"human\" : \"qualified_automatic\",\n qualification: settings.humanReviewRequired ? null : previous?.admission.qualification ?? null,\n minimumApprovedExamples: settings.minimumApprovedExamples },\n trigger,\n trainingParent: refs?.trainingParent ?? previous?.trainingParent,\n teacher: previous?.teacher ?? null,\n training: { method, recipe: refs?.recipe ?? previous?.training.recipe,\n retentionEvaluation: refs?.retentionEvaluation ?? previous?.training.retentionEvaluation,\n replayBatches: previous?.training.replayBatches ?? [] },\n limits: { maxIterationSpendUsd: settings.maxIterationSpendUsd, maxDailySpendUsd: settings.maxDailySpendUsd,\n cooldownSeconds: settings.cooldownSeconds, maxRetries: settings.maxRetries,\n maxBatchExamples: settings.maxBatchExamples, maxBacklogExamples: settings.maxBacklogExamples },\n automation: { collect: false, train: trigger.kind !== \"manual\", accept: false, serve: false },\n acceptance: previous?.acceptance ?? { minimumScore: 0, maximumRetentionRegression: 0, requireImprovement: true, rollbackVersion: null },\n });\n}\n\n/** Bind a reviewed hosted Model configuration before asynchronous preparation.\n * Keep the established recipe identity: its id binds the whole Model revision,\n * including Harness and retention selections, while its hash binds the recipe.\n * Callers must obtain the summary from the authenticated Model API. */\nexport function hostedLearningPolicyReferences(project: HostedModelProjectSummary) {\n const setup = project.trainingSetup;\n const base = setup.baseModel ?? project.defaultBaseModel;\n if (!setup.recipe || !base || !setup.evaluationTasksetRef) {\n throw new LearningDomainError(\"learning_model_configuration_incomplete\", 422,\n \"Select a training recipe, starting model and retained evaluation before enabling hosted learning.\");\n }\n return {\n recipe: { id: `model-recipe-${project.etag}`, contentHash: contentHash(setup.recipe) },\n trainingParent: { id: base.modelId, contentHash: contentHash(base) },\n retentionEvaluation: { id: setup.evaluationTasksetRef.id, contentHash: setup.evaluationTasksetRef.contentHash },\n };\n}\n","import { z } from \"zod\";\nimport { RewardReleaseSchema } from \"@openpond/evals/rewards\";\nconst Id = z.string().trim().min(1).max(240);\nexport const GraderCatalogQuerySchema = z.object({ projectId: Id.optional(), search: z.string().max(300).optional(), kind: z.string().max(100).optional(), sort: z.enum([\"name\", \"type\", \"version\", \"projects\", \"datasets\", \"runs\"]).optional(), direction: z.enum([\"asc\", \"desc\"]).optional(), after: z.string().max(3000).optional(), limit: z.number().int().min(1).max(100).default(30) }).strict();\nexport const GraderCatalogPageSchema = z.object({ teamId: Id, items: z.array(z.object({ reward: RewardReleaseSchema, projects: z.number().int().nonnegative(), datasets: z.number().int().nonnegative(), runs: z.number().int().nonnegative() }).strict()).max(100), nextCursor: z.string().nullable() }).strict();\nexport const GraderVersionsPageSchema = z.object({ teamId: Id, id: Id, items: z.array(RewardReleaseSchema).max(100), nextRevision: z.number().int().positive().nullable() }).strict();\nexport const GraderUsageQuerySchema = z.object({ section: z.enum([\"projects\", \"datasets\", \"runs\"]), after: Id.optional(), limit: z.number().int().min(1).max(100).default(25) }).strict();\nexport const GraderUsagePageSchema = z.object({ teamId: Id, id: Id, section: GraderUsageQuerySchema.shape.section, items: z.array(z.union([\n z.object({ id: Id, name: z.string(), graderRevisions: z.array(z.number().int().positive()), archived: z.boolean() }).strict(),\n z.object({ id: Id, name: z.string(), revision: z.number().int().positive(), graderRevisions: z.array(z.number().int().positive()) }).strict(),\n z.object({ id: Id, name: z.string(), status: z.string() }).strict(),\n])).max(100), nextCursor: Id.nullable() }).strict();\nexport class OpenPondGraderInspectionClient {\n private readonly baseUrl: string;\n constructor(private readonly options: { baseUrl: string; apiKey: string; teamId: string; fetch?: typeof fetch }) {\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.apiKey.trim() || !options.teamId.trim()) throw new Error(\"A clean API origin and workspace credentials are required.\");\n this.baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n async catalog(value: z.input<typeof GraderCatalogQuerySchema> = {}, signal?: AbortSignal) {\n const query = GraderCatalogQuerySchema.parse(value);\n const page = GraderCatalogPageSchema.parse(await this.read(\"\", query, signal));\n if (page.teamId !== this.options.teamId || page.items.length > query.limit || new Set(page.items.map(item => item.reward.id)).size !== page.items.length) throw new Error(\"Grader catalog differs from its requested workspace or bounds.\");\n return page;\n }\n async versions(id: string, query: { beforeRevision?: number; limit?: number } = {}, signal?: AbortSignal) {\n const options = z.object({ beforeRevision: z.number().int().positive().optional(), limit: z.number().int().min(1).max(100).default(25) }).strict().parse(query);\n const page = GraderVersionsPageSchema.parse(await this.read(`/${encodeURIComponent(Id.parse(id))}/versions`, options, signal));\n if (page.teamId !== this.options.teamId || page.id !== id || page.items.length > options.limit || page.items.some((item, index) => item.id !== id || options.beforeRevision && item.revision >= options.beforeRevision || index > 0 && item.revision >= page.items[index - 1]!.revision)) throw new Error(\"Grader versions differ from their requested identity or revision order.\");\n return page;\n }\n async usage(id: string, value: z.input<typeof GraderUsageQuerySchema>, signal?: AbortSignal) {\n const query = GraderUsageQuerySchema.parse(value);\n const page = GraderUsagePageSchema.parse(await this.read(`/${encodeURIComponent(Id.parse(id))}/usage`, query, signal));\n if (page.teamId !== this.options.teamId || page.id !== id || page.section !== query.section || page.items.length > query.limit) throw new Error(\"Grader usage differs from its requested workspace, identity or bounds.\");\n return page;\n }\n private async read(path: string, query: Record<string, unknown>, signal?: AbortSignal) {\n const params = new URLSearchParams(Object.entries(query).filter(([, value]) => value !== undefined).map(([key, value]) => [key, String(value)]));\n const response = await (this.options.fetch ?? fetch)(`${this.baseUrl}/v1/learning/read/graders${path}?${params}`, { signal, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"X-OpenPond-Team-Id\": this.options.teamId, Accept: \"application/json\" } });\n const value: unknown = await response.json();\n if (!response.ok) throw new Error(z.object({ error: z.string() }).parse(value).error);\n return value;\n }\n}\n","import { contentHash } from \"@openpond/harness\";\n\n/** Draft presentation default. Published keys must retain their released value. */\nexport function graderFeedbackKeyFromName(name: string, rewardId: string): string {\n const slug = name.normalize(\"NFKD\").toLowerCase().replace(/[^a-z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\");\n const prefix = /^[a-z]/.test(slug) ? slug : `grader_${slug}`;\n return `${(prefix || \"grader\").slice(0, 55).replace(/_+$/g, \"\")}_${contentHash(rewardId).slice(0, 24)}`;\n}\n","import { z } from \"zod\";\nimport { CorrectionVerificationPlanContentSchema, CorrectionVerificationPlanSchema, CorrectionOpportunitySchema, CorrectionMetricSummarySchema, CorrectionMetricObservationSchema, assertLearningRequestJson } from \"@openpond/evals/learning\";\nimport { OpenPondLearningError, readBoundedLearningResponse, type LearningRequestOptions } from \"./learning-client.js\";\nexport { CorrectionVerificationPlanSchema, CorrectionMetricSummarySchema, CorrectionMetricObservationSchema } from \"@openpond/evals/learning\";\nexport type { CorrectionVerificationPlan, CorrectionMetricSummary, CorrectionMetricObservation } from \"@openpond/evals/learning\";\nconst id = z.string().trim().min(1).max(500);\nconst ref = z.object({ id, contentHash: z.string().regex(/^[a-f0-9]{64}$/) }).strict();\nexport const CorrectionMetricsReadSchema = z.object({ teamId: id, modelId: id, runId: id.optional(), from: z.string().datetime().optional(), to: z.string().datetime().optional() }).strict();\nexport const CorrectionMetricsCommandSchema = z.discriminatedUnion(\"action\", [\n z.object({ action: z.literal(\"declare_verification\"), teamId: id, operationId: id,\n plan: z.object({\n modelId: CorrectionVerificationPlanContentSchema.shape.modelId,\n classification: CorrectionVerificationPlanContentSchema.shape.classification,\n feedback: CorrectionVerificationPlanContentSchema.shape.feedback,\n evidence: CorrectionVerificationPlanContentSchema.shape.evidence,\n trainingJobId: CorrectionVerificationPlanContentSchema.shape.trainingJobId,\n checkpoint: CorrectionVerificationPlanContentSchema.shape.checkpoint,\n artifact: CorrectionVerificationPlanContentSchema.shape.artifact,\n taskset: CorrectionVerificationPlanContentSchema.shape.taskset,\n checks: CorrectionVerificationPlanContentSchema.shape.checks,\n baselineOperationId: CorrectionVerificationPlanContentSchema.shape.baselineOperationId,\n candidateOperationId: CorrectionVerificationPlanContentSchema.shape.candidateOperationId,\n criterion: CorrectionVerificationPlanContentSchema.shape.criterion,\n }).strict() }).strict(),\n z.object({ action: z.literal(\"link_live_opportunity\"), teamId: id, operationId: id, correction: ref, inferenceRequestId: id,\n grade: z.object({ id, revision: z.number().int().positive() }).strict(), checkIds: z.array(id).min(1).max(1000) }).strict(),\n]);\nexport const CorrectionMetricsDetailSchema = z.object({ summary: CorrectionMetricSummarySchema.nullable(), observations: z.array(CorrectionMetricObservationSchema).max(1000) }).strict();\nexport type CorrectionMetricsRead = z.infer<typeof CorrectionMetricsReadSchema>;\nexport type CorrectionMetricsCommand = z.infer<typeof CorrectionMetricsCommandSchema>;\nexport class OpenPondCorrectionMetricsClient {\n private readonly options: { baseUrl: string; apiKey: string; fetch?: typeof globalThis.fetch };\n constructor(options: { baseUrl: string; apiKey: string; fetch?: typeof globalThis.fetch }) {\n if (!options.apiKey.trim()) throw new Error(\"Learning API key is required.\");\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash)\n throw new Error(\"Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.\");\n this.options = { ...options, baseUrl: url.toString().replace(/\\/+$/, \"\") };\n }\n private async request(path: string, teamId: string, init: RequestInit) {\n const response = await (this.options.fetch ?? globalThis.fetch)(`${this.options.baseUrl}${path}`, {\n ...init, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"Content-Type\": \"application/json\", Accept: \"application/json\", \"X-OpenPond-Team-Id\": teamId },\n });\n let payload: unknown;\n try { payload = await readBoundedLearningResponse(response); }\n catch (error) {\n if (error instanceof OpenPondLearningError) throw error;\n throw new OpenPondLearningError(response.ok ? 502 : response.status, \"invalid_response\", \"Correction metrics returned an invalid response.\", null);\n }\n if (!response.ok) {\n const error = z.object({ code: z.string().optional(), error: z.string().optional() }).passthrough().safeParse(payload);\n throw new OpenPondLearningError(response.status, error.success ? error.data.code ?? \"correction_request_failed\" : \"correction_request_failed\",\n error.success ? error.data.error ?? `Correction metrics request failed (${response.status}).` : `Correction metrics request failed (${response.status}).`, payload);\n }\n return payload;\n }\n async read(input: CorrectionMetricsRead, options: LearningRequestOptions = {}) {\n const query = CorrectionMetricsReadSchema.parse(input);\n const result = CorrectionMetricsDetailSchema.parse(await this.request(`/v1/learning/corrections?query=${encodeURIComponent(JSON.stringify(query))}`, query.teamId, { method: \"GET\", signal: options.signal }));\n if (result.summary && (result.summary.scope.teamId !== query.teamId || result.summary.scope.modelId !== query.modelId || query.runId && result.summary.scope.runId !== query.runId)\n || result.observations.some(observation => observation.modelId !== query.modelId || query.runId && observation.trainingJobId !== query.runId))\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction metrics did not match the requested workspace, Model or run.\", null);\n return result;\n }\n async command(input: CorrectionMetricsCommand, options: LearningRequestOptions = {}) {\n const command = CorrectionMetricsCommandSchema.parse(input);\n assertLearningRequestJson(command);\n const payload = await this.request(\"/v1/learning/corrections\", command.teamId, { method: \"POST\", body: JSON.stringify(command), signal: options.signal });\n if (command.action === \"declare_verification\") {\n const result = CorrectionVerificationPlanSchema.parse(payload);\n if (result.teamId !== command.teamId || result.modelId !== command.plan.modelId || result.trainingJobId !== command.plan.trainingJobId)\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction declaration did not match the requested workspace, Model or run.\", null);\n return result;\n }\n const result = CorrectionOpportunitySchema.parse(payload);\n if (result.correction.id !== command.correction.id || result.correction.contentHash !== command.correction.contentHash || result.attempt.id !== command.inferenceRequestId)\n throw new OpenPondLearningError(502, \"correction_scope_mismatch\", \"Correction opportunity did not match the declared correction and serving request.\", null);\n return result;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,cAAc;;;ACDd,SAAS,qBAAqB,6BAA6B,6BAA6B,aAAa,iBAAiB,2BAA+F;AAQ9M,SAAS,2BAA2B,OAA2G;AACpJ,QAAM,WAAW,2BAA2B,MAAM,MAAM,QAAQ;AAChE,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,MAAI,CAAC,QAAQ,cAAc,oBAAoB,CAAC,gBAAgB,WAAW,eAAe,QAAQ,cAAc,gBAAgB,EAAG,OAAM,IAAI,oBAAoB,oCAAoC,KAAK,uDAAuD;AACjQ,QAAM,SAAS,4BAA4B,MAAM;AAAA,IAAE,eAAe;AAAA,IAA8B,IAAI,gBAAgB,YAAY,CAAC,QAAQ,mBAAmB,YA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I;AACnJ,WAAO;AAAA,EACT;AAAA,EACA,MAAM,QAAQ,OAAiC,UAAkC,CAAC,GAAG;AACnF,UAAM,UAAU,+BAA+B,MAAM,KAAK;AAC1D,8BAA0B,OAAO;AACjC,UAAM,UAAU,MAAM,KAAK,QAAQ,4BAA4B,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,MAAM,KAAK,UAAU,OAAO,GAAG,QAAQ,QAAQ,OAAO,CAAC;AACxJ,QAAI,QAAQ,WAAW,wBAAwB;AAC7C,YAAMC,UAAS,iCAAiC,MAAM,OAAO;AAC7D,UAAIA,QAAO,WAAW,QAAQ,UAAUA,QAAO,YAAY,QAAQ,KAAK,WAAWA,QAAO,kBAAkB,QAAQ,KAAK;AACvH,cAAM,IAAI,sBAAsB,KAAK,6BAA6B,+EAA+E,IAAI;AACvJ,aAAOA;AAAA,IACT;AACA,UAAM,SAAS,4BAA4B,MAAM,OAAO;AACxD,QAAI,OAAO,WAAW,OAAO,QAAQ,WAAW,MAAM,OAAO,WAAW,gBAAgB,QAAQ,WAAW,eAAe,OAAO,QAAQ,OAAO,QAAQ;AACtJ,YAAM,IAAI,sBAAsB,KAAK,6BAA6B,qFAAqF,IAAI;AAC7J,WAAO;AAAA,EACT;AACF;","names":["id","value","z","CorrectionVerificationPlanSchema","CorrectionMetricSummarySchema","CorrectionMetricObservationSchema","z","result"]}
@@ -16,7 +16,7 @@ import {
16
16
  postTrainingActive,
17
17
  postTrainingRecipe,
18
18
  verifyPostTrainingPlan
19
- } from "./chunk-VPK3SM45.js";
19
+ } from "./chunk-BJMENXR4.js";
20
20
  import "./chunk-ZQFROKKS.js";
21
21
  import "./chunk-GS5HEE4M.js";
22
22
  import "./chunk-ZRTNR4U7.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-UVQENVTW.js";
17
17
  import {
18
18
  TrainingHandoffOriginSchema
19
- } from "./chunk-VPK3SM45.js";
19
+ } from "./chunk-BJMENXR4.js";
20
20
  import {
21
21
  HarnessSourceSelectionSchema,
22
22
  createAgentSnapshot,